[英]pip3 says “resolve pkg_resources.DistributionNotFound: pip==1.3.1”
On OSX 10.7.5, I'm trying to use the pip3
command to install packages to python3.在 OSX 10.7.5 上,我尝试使用
pip3
命令将软件包安装到 python3。 When I try, I get this error message:当我尝试时,我收到此错误消息:
zak$ pip3
Traceback (most recent call last):
File "/usr/local/Cellar/python3/3.3.2/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/setuptools-1.0-py3.3.egg/pkg_resources.py", line 2793, in <module>
File "/usr/local/Cellar/python3/3.3.2/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/setuptools-1.0-py3.3.egg/pkg_resources.py", line 673, in require
File "/usr/local/Cellar/python3/3.3.2/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/setuptools-1.0-py3.3.egg/pkg_resources.py", line 580, in resolve
pkg_resources.VersionConflict: (pip 1.4.1 (/usr/local/lib/python3.3/site-packages), Requirement.parse('pip==1.3.1'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 5, in <module>
from pkg_resources import load_entry_point
File "<frozen importlib._bootstrap>", line 1567, in _find_and_load
File "<frozen importlib._bootstrap>", line 1534, in _find_and_load_unlocked
File "/usr/local/Cellar/python3/3.3.2/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/setuptools-1.0-py3.3.egg/pkg_resources.py", line 2797, in <module>
File "/usr/local/Cellar/python3/3.3.2/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/setuptools-1.0-py3.3.egg/pkg_resources.py", line 576, in resolve
pkg_resources.DistributionNotFound: pip==1.3.1
It looks like setuptools
is demanding an old version of pip (I have 1.4.1 installed), but why?看起来
setuptools
需要旧版本的 pip(我安装了 1.4.1),但为什么呢? How can I fix this?我怎样才能解决这个问题?
The problem appears to be that you have two different Python 3.3 installations, and a shared site-packages directory.* And the tool you run as pip3
is from pip 1.3.1, but the modules it uses to do its work come from pip 1.4.1.问题似乎是您有两个不同的 Python 3.3 安装和一个共享的 site-packages 目录。* 您作为
pip3
运行的工具来自 pip 1.3.1,但它用来完成工作的模块来自 pip 1.4 .1.
The easiest way to solve this, unless you actually need both Python 3.3 installations, is to get rid of both of them completely, then reinstall the one you want.解决此问题的最简单方法,除非您确实需要同时安装两个 Python 3.3,否则将它们都完全删除,然后重新安装您想要的那个。
The following should work (possibly with sudo
for some of the commands—or using Finder and letting it tell you whether you need to authenticate).以下应该可以工作(可能对某些命令使用
sudo
或使用 Finder 并让它告诉您是否需要进行身份验证)。
Note that this will also partially or completely remove any other third-party Python versions (eg, a python.org 2.7.5), which I don't think is a problem for you, but could be for future readers.请注意,这也将部分或完全删除任何其他第三方 Python 版本(例如,python.org 2.7.5),我认为这对您来说不是问题,但对未来的读者来说可能是问题。
You might want to make a list of all installed packages before uninstalling anything.在卸载任何东西之前,您可能希望列出所有已安装的软件包。 (I usually do this in the hackiest way possible: fire up
ipython
, and let it tab-complete an import statement…) (我通常以最黑客的方式执行此操作:启动
ipython
,并让它完成一个导入语句......)
Finally, some of these details will be different for any future readers with similar problems, but the basic ideas should be the same.最后,对于以后遇到类似问题的读者来说,其中一些细节会有所不同,但基本思想应该是相同的。
brew uninstall python3
rm -rf /Library/Frameworks/Python.framework
rm -rf /usr/local/lib/python*
rm -rf /usr/local/share/python*
~/.bash_profile
(or ~/.profile
or elsewhere) you add the Python paths to your PATH.~/.bash_profile
(或~/.profile
或其他地方)中找到将 Python 路径添加到 PATH 的位置。 You may have /usr/local/share/python3
and/or something inside the Python.framework
or Cellar/python3
./usr/local/share/python3
和/或Python.framework
或Cellar/python3
某些内容。 Scrap all that you find.brew doctor
, and fix anything that it complains about that seems potentially relevant (the non-Homebrew MacFUSE stuff is fine as-is; the brew prune
suggestion is probably worth doing, but doesn't matter here), and run it again to make sure. brew doctor
,并修复它抱怨的任何似乎可能相关的东西(非 Homebrew MacFUSE 的东西按原样很好; brew prune
建议可能值得做,但在这里无关紧要),然后再次运行它以制作当然。brew install python3
. brew install python3
。pip3
to reinstall any packages you deleted that you need again. pip3
以重新安装您删除的所有需要的软件包。 * Details: * 细节:
/usr/local/Cellar/python3/3.3.2/
, with various things symlinked into /usr/local/bin
and its siblings, and possibly into /Library
somewhere. /usr/local/Cellar/python3/3.3.2/
,各种东西被符号链接到/usr/local/bin
和它的兄弟,可能到/Library
某个地方。/Library/Frameworks/Python.framework/Versions/3.3/
, with various things possibly symlinked into /usr/local/bin
or otherwise added to your PATH./Library/Frameworks/Python.framework/Versions/3.3/
,各种内容可能被符号链接到/usr/local/bin
或以其他方式添加到您的 PATH 中。/usr/local/lib/python3.3
in their site-packages search./usr/local/lib/python3.3
。After running运行后
pip install --upgrade setuptools
I was able to fix it.我能够修复它。 But this may not be true for everyone for I am still learning Python.
但这可能并不适用于每个人,因为我仍在学习 Python。
这似乎是由损坏的 Python 安装引起的,我可以通过使用 Homebrew 重新安装 Python 来修复它。
brew reinstall python3
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.