Python 错误:“导入错误:没有名为 6 的模块”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21222458/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Python Error: "ImportError: No module named six"
提问by panterasBox
I am running Python 2.7 on a Windows 7 OS
我在 Windows 7 操作系统上运行 Python 2.7
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
现在,我从这里下载了六个: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?
我解压缩它,如果我从那里打开一个名为 setup.py 的文件,然后我尝试导入 matplotlib 然后它就可以工作了,但是我不必每次都想制作绘图时都这样做,对吗?没有办法让它自动工作吗?
采纳答案by tripleee
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.
您需要在您的系统上安装它。这基本上意味着将 zip 文件放在 Python 可以找到的地方,但目前最简单的方法是 .zip 文件pip install six。不过,这将再次下载它。
Like the matplotlib installation instructionsmention, sixis a dependency of the dateutilpackage. Most sane installation methods would pull in this dependency automatically; if you had done pip install python-dateutilin 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.
就像matplotlib 安装说明提到的,six是dateutil包的依赖项。大多数合理的安装方法会自动引入这种依赖关系;如果你一开始就这样做pip install python-dateutil了,这个缺失的依赖应该在幕后得到满足。如果您需要完全手动安装,则应仔细阅读这些说明。
回答by MattDMo
At the command line, navigate to the folder that contains the setup.pyand run
在命令行中,导航到包含setup.py并运行的文件夹
python setup.py install
This will install the sixpackage in your Python site-packagesfolder where all 3rd-party modules live. You should now be able to import matplotlib without any problems.
这会将six软件包安装site-packages在所有 3rd-party 模块所在的 Python文件夹中。您现在应该可以毫无问题地导入 matplotlib。
回答by SherMM
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
我可能会迟到,但我遇到了同样的问题。在我 pip 安装了 Pandas 之后,问题就消失了。清理后,我收到了这条消息
"Successfully installed pandas pytz six"
《成功安装pandas pytz 6》
回答by user1866080
Copy six.py and six.pyc to \Lib.
将 Six.py 和 Six.pyc 复制到 \Lib。
回答by Saideep
After fighting long found the way it works. Python 3.4 version.
经过长时间的战斗找到了它的工作方式。Python 3.4 版本。
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.
实际上,很多人说您可以将六个包下载为 .zip 文件并将内容提取到“站点包”文件夹(C:\Python34\Lib\site-packages)中,以便包含“六个”模块的init.py 文件属于从那里读取。
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.
在此之后,当我们运行 python 脚本时,从init.py的同一个文件中,我们运行了 4-5 个模块错误,说明该模块不可用。经过长时间的搜索,我发现这个页面非常有用,然后继续处理 IDLE 状态的错误。
Good luck!"
祝你好运!”
回答by mcoolive
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.
我猜之前的安装在完全终止之前中止了。或者可能是权限问题。或者其他什么......现在调查真正原因为时已晚。
回答by kris433
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.
对我来说,我安装了两个版本的 matplotlib。只需运行“pip uninstall matplotlib”,然后再次运行“pip install matplotlib”。对我来说,多次加载搞砸了一切。首先尝试这个,如果它没有帮助,请转到下一步。

