12

I am running Python 2.7 on a Windows 7 OS

Here is what I run:

>>> import matplotlib.pyplot as plt

Then I get this:

Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    import matplotlib.pyplot as plt
  File "C:\Python27\lib\site-packages\matplotlib\pyplot.py", line 29, in <module>
    from matplotlib.figure import Figure, figaspect
  File "C:\Python27\lib\site-packages\matplotlib\figure.py", line 36, in <module>
    from matplotlib.axes import Axes, SubplotBase, subplot_class_factory
  File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 20, in <module>
    import matplotlib.dates as _  # <-registers a date unit converter
  File "C:\Python27\lib\site-packages\matplotlib\dates.py", line 119, in <module>
    from dateutil.rrule import (rrule, MO, TU, WE, TH, FR, SA, SU, YEARLY,
  File "C:\Python27\lib\site-packages\dateutil\rrule.py", line 18, in <module>
    from six import advance_iterator, integer_types
ImportError: No module named six

Now, I have downloaded six from here : https://pypi.python.org/pypi/six

I unzipped it and if I open up a file from there called setup.py and then I try to import matplotlib then it works, but I don;t have to do this every time I want to make a plot do I? Isn't there a way to get this to work automatically?

Charles
  • 50,943
  • 13
  • 104
  • 142
statsNoob
  • 1,325
  • 5
  • 18
  • 36
  • @shx2, please always make sure to [search using the full tag list](http://stackoverflow.com/tags) before creating a new tag with a short name. We already have a tag for six, it just had a low enough question count to not show up in the autocomplete. – Charles Feb 13 '14 at 21:32

7 Answers7

19

You need to install it on your system. This basically means putting the zip file where Python can find it, but by far the easiest way is pip install six. This will download it a second time, though.

Like the matplotlib installation instructions mention, six is a dependency of the dateutil package. Most sane installation methods would pull in this dependency automatically; if you had done pip install python-dateutil in the first place, this missing dependency should have been satisfied behind the scenes. If you require a completely manual installation, you should give those instructions a thorough read.

tripleee
  • 175,061
  • 34
  • 275
  • 318
  • 1
    Or, they can do `pip install six.tar.gz` or whatever the zip file was called. This way it won't download again. – SethMMorton Jan 19 '14 at 20:57
  • You might need to install `pip` before this will work. The http://pypi.python.org/ start page has all the documentation you need. – tripleee Jan 19 '14 at 22:27
  • 1
    I found to install `dateutil`, you need to use `pip install python-dateutil` – RaelB Aug 27 '15 at 10:00
  • 1
    Why are these pip modules not correctly installing their dependencies? This is a hack fix, but doesn't solve the problem. – swade May 27 '16 at 13:46
  • @StevenWade I'm guessing the OP didn't use `pip` and that that's the root of the problem. – tripleee May 27 '16 at 14:24
8

I got exactly the same error message. And it seams there are many many possible causes. In my case, I solved the issue by reinstalling six

pip uninstall six ; pip install six

I guess the previous installation was aborted before a complete termination. Or maybe a permission issue. Or something else ... now it's too late to investigate what was the real cause.

mcoolive
  • 3,805
  • 1
  • 27
  • 32
2

for me i had two versions of matplotlib installed. Just run "pip uninstall matplotlib", and again run "pip install matplotlib". For me multiple doenloads messed up everything. First try this, and if it does not help move to the next steps.

kris433
  • 414
  • 5
  • 17
1

At the command line, navigate to the folder that contains the setup.py and run

python setup.py install

This will install the six package in your Python site-packages folder where all 3rd-party modules live. You should now be able to import matplotlib without any problems.

MattDMo
  • 100,794
  • 21
  • 241
  • 231
1

Copy six.py and six.pyc to \Lib.

user1866080
  • 35
  • 1
  • 4
1

After fighting long found the way it works. Python 3.4 version.

Actually as many say you can download the six package as .zip file and extract the content in the "site packages" folder (C:\Python34\Lib\site-packages) so that the init.py file that includes "six" module is belong read from there.

After this from the same file of init.py when we run the python script we run 4-5 module errors stating the module is not available. I found this page extremely useful after long search and just follow on with the errors IDLE states.

Good luck!"

Saideep
  • 61
  • 1
  • 6
0

I might be late to this, but I was having the same problem. After I pip installed Pandas though, the problem went away. After the cleanup, I got this message

"Successfully installed pandas pytz six"

SherMM
  • 619
  • 6
  • 14