gpt4 book ai didi

python - pip 给出 "ImportError: No module named setuptools"但我可以在 python 解释器中导入 setuptools

转载 作者:太空狗 更新时间:2023-10-29 21:44:02 26 4
gpt4 key购买 nike

我正在一台新的 Mac 上进行设置,我一直在嗡嗡作响,安装了 pip 和一些软件包。突然间,我尝试运行的每个 pip 命令都会抛出

Exception:
Traceback (most recent call last):
File "/Library/Python/2.6/site-packages/pip-1.2.1-py2.6.egg/pip/basecommand.py", line 107, in main
status = self.run(options, args)
File "/Library/Python/2.6/site-packages/pip-1.2.1-py2.6.egg/pip/commands/install.py", line 248, in run
import setuptools
ImportError: No module named setuptools

我想我不小心删除了一个目录或其他东西,所以我按照 other answers 的建议尝试重新安装 setuptools在这个网站上。我从 here 下载了 setuptools egg并像 shell 脚本一样运行它。得到这个输出:

Processing setuptools-0.6c11-py2.7.egg
Removing /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg
Copying setuptools-0.6c11-py2.7.egg to /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
setuptools 0.6c11 is already the active version in easy-install.pth
Installing easy_install script to /Library/Frameworks/Python.framework/Versions/2.7/bin
Installing easy_install-2.7 script to /Library/Frameworks/Python.framework/Versions/2.7/bin

Installed /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg
Processing dependencies for setuptools==0.6c11
Finished processing dependencies for setuptools==0.6c11

现在,如果我启动一个交互式 python session ,我可以import setuptools 而不会出错,但是 pip(和其他命令行脚本)会提示它没有安装。为什么 Python 似乎找到了它,但其他脚本却找不到?有什么想法吗?

如果有帮助,这是 sys.path 中的内容:

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg
/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages

最佳答案

您的 pip 似乎与您的 Python 不一致。比较:

File "/Library/Python/2.6/site-packages/pip-1.2.1-py2.6.egg/pip/basecommand.py", line 107, in main

Installed /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg

如果python2.7有setuptools,那么你应该有

/Library/Frameworks/Python.framework/Versions/2.7/bin/easy_install-2.7

可用,在这种情况下

easy_install-2.7 pip

应该给你 pip-2.7

关于python - pip 给出 "ImportError: No module named setuptools"但我可以在 python 解释器中导入 setuptools,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12335662/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com