简体   繁体   English

pip3 说“解决 pkg_resources.DistributionNotFound:pip==1.3.1”

[英]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*
  • Find where in ~/.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.frameworkCellar/python3某些内容。 Scrap all that you find.废弃你找到的所有东西。
  • Fire up a new shell in Terminal.app.在 Terminal.app 中启动一个新的 shell。
  • 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: * 细节:

  • Homebrew Python 3.3 is installed in /usr/local/Cellar/python3/3.3.2/ , with various things symlinked into /usr/local/bin and its siblings, and possibly into /Library somewhere. Homebrew Python 3.3 安装在/usr/local/Cellar/python3/3.3.2/ ,各种东西被符号链接到/usr/local/bin和它的兄弟,可能到/Library某个地方。
  • Another Python 3.3, possibly from the python.org installer, is installed in /Library/Frameworks/Python.framework/Versions/3.3/ , with various things possibly symlinked into /usr/local/bin or otherwise added to your PATH.另一个可能来自 python.org 安装程序的 Python 3.3 安装在/Library/Frameworks/Python.framework/Versions/3.3/ ,各种内容可能被符号链接到/usr/local/bin或以其他方式添加到您的 PATH 中。
  • Both probably include /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.

相关问题 Python pip说:pkg_resources.DistributionNotFound:pip == 1.4.1 - Python pip says: pkg_resources.DistributionNotFound: pip==1.4.1 Python pip pkg_resources.DistributionNotFound - Python pip pkg_resources.DistributionNotFound python pip 错误 pkg_resources.DistributionNotFound - python pip error pkg_resources.DistributionNotFound Ubuntu 18.04中的PIP问题(pkg_resources.DistributionNotFound:找不到&#39;pip == 10.0.1&#39;分布,是应用程序所必需的) - PIP issue in Ubuntu 18.04 (pkg_resources.DistributionNotFound: The 'pip==10.0.1' distribution was not found and is required by the application) Easy_install和pip broken:pkg_resources.DistributionNotFound:distribute == 0.6.36 - Easy_install and pip broke: pkg_resources.DistributionNotFound: distribute==0.6.36 pkg_resources.DistributionNotFound:&#39;jsonschema&#39; - pkg_resources.DistributionNotFound: 'jsonschema' pkg_resources.DistributionNotFound:PIL - pkg_resources.DistributionNotFound: PIL pkg_resources.DistributionNotFound:在Django中创建新项目时Django == 1.3.1 - pkg_resources.DistributionNotFound: Django==1.3.1 while creating a new project in Django pkg_resources.DistributionNotFound:Scrapy == 1.3.0 - pkg_resources.DistributionNotFound: Scrapy==1.3.0 对 pkg_resources.DistributionNotFound 错误进行故障排除 - Troubleshooting pkg_resources.DistributionNotFound error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM