gpt4 book ai didi

python - "/lib/python2.7/site-packages/does NOT support .pth files"在 MacOS 上安装 pip

转载 作者:行者123 更新时间:2023-11-28 20:14:24 25 4
gpt4 key购买 nike

我在我的 mac 上使用 pip 遇到了一些问题,然后完全卸载了它。

现在,当我尝试重新安装它时,运行 $sudo easy_install pip 我得到:

TEST FAILED: /lib/python2.7/site-packages/ does NOT support .pth files
error: bad install directory or PYTHONPATH

You are attempting to install a package to a directory that is not
on PYTHONPATH and which Python does not read ".pth" files from. The
installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

/lib/python2.7/site-packages/

and your PYTHONPATH environment variable currently contains:

''

[此粘贴输出为简洁起见缩短]


我尝试使用 ./profile 和 ./bash_profile 将列出的目录 (/lib/python2.7/site-packages/) 添加到我的 pythonpath 中,但是当我运行 python 时,它们都不会影响 sys.path 变量,其中仅包括

/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload
/Library/Python/2.7/site-packages
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC

我的问题是我安装了两个版本的 python(在列出的两个目录下)吗?

还是我的 pythonpath 被搞砸了,我一直无法补救?


编辑:

$ which python 返回 /usr/bin/python

$ which easy_install 返回 /usr/bin/easy_install

最佳答案

我想通了。

当我尝试通过 brew 安装 python2,然后运行 ​​brew doctor 我收到以下警告。

Warning: A .pydistutils.cfg file was found in $HOME, which may cause Python
builds to fail. See:
https://bugs.python.org/issue6138
https://bugs.python.org/issue4655

果然,当我删除 .pydistutils.cfg 时,问题就解决了。


FWIW,这是让我开始创建文件的 SO 问题:

Combine --user with --prefix error with setup.py install

(那里的答案确实提到它可能会导致意想不到的后果。我只是认为链接到它可能有助于搜索当前遇到与我遇到的相同问题但忘记了他们创建了该文件的任何人的可见性。)

关于python - "/lib/python2.7/site-packages/does NOT support .pth files"在 MacOS 上安装 pip,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50093030/

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