我们最近卸载了pip,在Mac OS X El Capitan上做了一些清理工作。现在尝试重新安装pip。
$ sudo easy_install pip
Traceback (most recent call last):
File "/usr/local/bin/easy_install", line 11, in <module>
sys.exit(main())
File "/Library/Python/2.7/site-packages/setuptools/command/easy_install.py", line 2270, in main
**kw
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 111, in setup
_setup_distribution = dist = klass(attrs)
File "/Library/Python/2.7/site-packages/setuptools/dist.py", line 321, in __init__
_Distribution.__init__(self, attrs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 287, in __init__
self.finalize_options()
File "/Library/Python/2.7/site-packages/setuptools/dist.py", line 389, in finalize_options
ep.require(installer=self.fetch_build_egg)
File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 2324, in require
items = working_set.resolve(reqs, env, installer, extras=self.extras)
File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 859, in resolve
raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.VersionConflict: (six 1.4.1 (/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python), Requirement.parse('six>=1.6.0'))
看起来我们需要升级Six。所以:
$ easy_install --upgrade six
Traceback (most recent call last):
File "/usr/local/bin/easy_install", line 11, in <module>
sys.exit(main())
File "/Library/Python/2.7/site-packages/setuptools/command/easy_install.py", line 2270, in main
**kw
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 111, in setup
_setup_distribution = dist = klass(attrs)
File "/Library/Python/2.7/site-packages/setuptools/dist.py", line 321, in __init__
_Distribution.__init__(self, attrs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 287, in __init__
self.finalize_options()
File "/Library/Python/2.7/site-packages/setuptools/dist.py", line 389, in finalize_options
ep.require(installer=self.fetch_build_egg)
File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 2324, in require
items = working_set.resolve(reqs, env, installer, extras=self.extras)
File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 859, in resolve
raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.VersionConflict: (six 1.4.1 (/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python), Requirement.parse('six>=1.6.0'))
现在看来我们需要升级Six才能升级Six ???也许它只是一个权限问题:
$sudo easy_install --upgrade six
Traceback (most recent call last):
File "/usr/local/bin/easy_install", line 11, in <module>
sys.exit(main())
File "/Library/Python/2.7/site-packages/setuptools/command/easy_install.py", line 2270, in main
**kw
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 111, in setup
_setup_distribution = dist = klass(attrs)
File "/Library/Python/2.7/site-packages/setuptools/dist.py", line 321, in __init__
_Distribution.__init__(self, attrs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 287, in __init__
self.finalize_options()
File "/Library/Python/2.7/site-packages/setuptools/dist.py", line 389, in finalize_options
ep.require(installer=self.fetch_build_egg)
File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 2324, in require
items = working_set.resolve(reqs, env, installer, extras=self.extras)
File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 859, in resolve
raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.VersionConflict: (six 1.4.1 (/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python), Requirement.parse('six>=1.6.0'))
不。同样的错误。
我显然错过了一些东西。有人可以对此有所了解吗?尝试了第一个答案:
$ python get-pip.py
Collecting pip
Using cached pip-9.0.1-py2.py3-none-any.whl
Collecting wheel
Using cached wheel-0.29.0-py2.py3-none-any.whl
Installing collected packages: pip, wheel
Exception:
Traceback (most recent call last):
File "/var/folders/23/49gg72xd4wb1qps4z5j9vbz80000gy/T/tmpz5ckOD/pip.zip/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/var/folders/23/49gg72xd4wb1qps4z5j9vbz80000gy/T/tmpz5ckOD/pip.zip/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/var/folders/23/49gg72xd4wb1qps4z5j9vbz80000gy/T/tmpz5ckOD/pip.zip/pip/req/req_set.py", line 784, in install
**kwargs
File "/var/folders/23/49gg72xd4wb1qps4z5j9vbz80000gy/T/tmpz5ckOD/pip.zip/pip/req/req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/var/folders/23/49gg72xd4wb1qps4z5j9vbz80000gy/T/tmpz5ckOD/pip.zip/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/var/folders/23/49gg72xd4wb1qps4z5j9vbz80000gy/T/tmpz5ckOD/pip.zip/pip/wheel.py", line 247, in move_wheel_files
prefix=prefix,
File "/var/folders/23/49gg72xd4wb1qps4z5j9vbz80000gy/T/tmpz5ckOD/pip.zip/pip/locations.py", line 140, in distutils_scheme
d = Distribution(dist_args)
File "/Library/Python/2.7/site-packages/setuptools/dist.py", line 321, in __init__
_Distribution.__init__(self, attrs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 287, in __init__
self.finalize_options()
File "/Library/Python/2.7/site-packages/setuptools/dist.py", line 389, in finalize_options
ep.require(installer=self.fetch_build_egg)
File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 2324, in require
items = working_set.resolve(reqs, env, installer, extras=self.extras)
File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 859, in resolve
raise VersionConflict(dist, req).with_context(dependent_req)
VersionConflict: (six 1.4.1 (/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python), Requirement.parse('six>=1.6.0'))
答案 0 :(得分:-1)
Python 2.7.9+和3.4 +
好消息! Python 3.4(2014年3月发布)和Python 2。7。9(2014年12月发布)随Pip一起发布。这是任何Python版本的最佳功能。它使每个人都可以访问社区丰富的图书馆。由于设置难度大,新手不再被排除在使用社区库之外。在使用包管理器时,Python加入了Ruby,Node.js,Haskell,Perl,Go - 几乎所有其他当代语言都拥有大多数开源社区。谢谢Python。当然,这并不意味着Python包装问题就解决了。这种经历仍令人沮丧。我在Stack Overflow问题中讨论这个问题Python是否有包/模块管理系统?。
并且,对于使用Python 2.7.8或更早版本(社区的相当大一部分)的每个人来说都是唉。没有计划将Pip发送给您。手动说明如下。 Python2≤2.7.8和Python3≤3.3
面对“含电池”的座右铭,Python没有包装管理器。更糟糕的是,Pip直到最近才讽刺地难以安装。 官方指示
每https://pip.pypa.io/en/stable/installing/#do-i-need-to-install-pip:
下载get-pip.py,小心将其保存为.py文件而不是.txt。然后,从命令提示符运行它:
python get-pip.py
您可能需要管理员命令提示符才能执行此操作。按照以管理员身份启动命令提示符(Microsoft TechNet)。 替代说明
官方文档告诉用户从源代码安装Pip及其每个依赖项。这对于有经验的人来说是乏味的,对新手来说太难了。
为了我们的缘故,Christoph Gohlke为流行的Python软件包准备了Windows安装程序(.msi)。他为所有Python版本(32位和64位)构建安装程序。你需要
Install setuptools
Install pip
对我来说,这是在C:\ Python27 \ Scripts \ pip.exe上安装了Pip。在您的计算机上找到pip.exe,然后将其文件夹(例如,C:\ Python27 \ Scripts)添加到您的路径(启动/编辑环境变量)。现在你应该可以从命令行运行pip了。尝试安装包:
pip install httpie
你去(希望)!常见问题的解决方案如下: 代理问题
如果您在办公室工作,您可能会在HTTP代理后面。如果是这样,请设置环境变量http_proxy和https_proxy。大多数Python应用程序(和其他免费软件)都尊重这些。语法示例:
http://proxy_url:port http://username:password@proxy_url:port
如果您真的不走运,您的代理可能是Microsoft NTLM代理。免费软件无法应付。唯一的解决方案是安装一个免费的软件友好代理,转发给令人讨厌的代理。 http://cntlm.sourceforge.net/ 无法找到vcvarsall.bat
Python模块可以用C或C ++编写。 Pip尝试从源代码编译。如果您没有安装和配置C / C ++编译器,您将看到这个神秘的错误消息。
Error: Unable to find vcvarsall.bat
您可以通过安装C ++编译器(如MinGW或Visual C ++)来解决此问题。微软实际上是专门为Python使用的。或者尝试使用Microsoft Visual C ++ Compiler for Python 2.7。
通常情况下,查看Christoph的网站是否更容易。