如何在Python2.7中安装六模块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21990581/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 00:02:42  来源:igfitidea点击:

How to install the Six module in Python2.7

pythonshared-librariespython-dateutilsix

提问by Ravi

I am using Python 2.7 and trying to use dateutilas follows:

我正在使用 Python 2.7 并尝试使用dateutil如下:

from dateutil import parser as _date_parser

However, I get the following error:

但是,我收到以下错误:

Traceback (most recent call last):
  File "<pyshell#17>", line 1, in <module>
    from dateutil import parser as _date_parser
  File "C:\Python27\Lib\dateutil\parser.py", line 24, in <module>
    from six import text_type, binary_type, integer_types
ImportError: No module named six

Could you please let me know what is the sixmodule for and how to get it installed in a Windows 7 machine?

您能否让我知道该six模块的用途以及如何将其安装在 Windows 7 机器上?

采纳答案by Oz123

You need to install this

你需要安装这个

https://pypi.python.org/pypi/six

https://pypi.python.org/pypi/six

If you still don't know what pip is , then please also google for pip install

如果你仍然不知道pip是什么,那么也请谷歌搜索 pip install

Python has it's own package manager which is supposed to help you finding packages and their dependencies: http://www.pip-installer.org/en/latest/

Python 有自己的包管理器,可以帮助您查找包及其依赖项:http: //www.pip-installer.org/en/latest/

回答by zmo

here's what sixis:

这就是

pip search six
six                       - Python 2 and 3 compatibility utilities

to install:

安装:

pip install six

though if you did install python-dateutilfrom pip six should have been set as a dependency.

但是,如果您确实python-dateutil从 pip安装,则应该将其设置为依赖项。

N.B.: to install pip run easy_install pipfrom command line.

注意:easy_install pip从命令行安装 pip run 。

回答by rustyMagnet

I had the same question for macOS.

我对 macOS 有同样的问题。

But the root cause was not installing Six. My macOS shipped Python version 2.7 was being usurped by a Python2 version I inherited by installing a package via brew.

但根本原因不是安装六。我的 macOS 发布的 Python 2.7 版被我通过brew.

I fixed my issue with: $ brew uninstall python@2

我解决了我的问题: $ brew uninstall python@2

Some context on here: https://bugs.swift.org/browse/SR-1061

这里的一些背景: https://bugs.swift.org/browse/SR-1061