gpt4 book ai didi

python - 无法使用 OS X El Capitan pip 安装任何东西

转载 作者:行者123 更新时间:2023-12-05 07:52:45 26 4
gpt4 key购买 nike

我正在尝试在 OS X El Capitan 上pip install virtualenv(和其他任何东西)并收到以下错误:

Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 211, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/site-packages/pip/commands/install.py", line 311, in run
root=options.root_path,
File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 646, in install
**kwargs
File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 803, in install
self.move_wheel_files(self.source_dir, root=root)
File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 998, in move_wheel_files
isolated=self.isolated,
File "/usr/local/lib/python2.7/site-packages/pip/wheel.py", line 339, in move_wheel_files
clobber(source, lib_dir, True)
File "/usr/local/lib/python2.7/site-packages/pip/wheel.py", line 282, in clobber
ensure_dir(dest) # common for the 'include' path
File "/usr/local/lib/python2.7/site-packages/pip/utils/__init__.py", line 71, in ensure_dir
os.makedirs(path)
File "/usr/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 1] Operation not permitted: '/usr/lib/python2.7/site-packages'

看起来 pip 正在尝试写入 '/usr/lib/python2.7/site-packages',但由于 El Capitan 中的 SIP,它被拒绝了。但是我想知道为什么 pip 需要写在那里?我该如何解决这个问题?

我运行了 brew doctor这给

Your system is ready to brew.

所以我觉得还可以。

我尝试了 brew reinstall python 并给出了一个奇怪的错误:

==> Reinstalling python
Error: /usr/local/opt/python is not a valid keg

哪个python给出了

/usr/local/bin/python

所以系统中哪里有这个让 pip 失败的奇怪东西

更新:

看起来我的 pip 指向系统 python 而不是 brewed python。我把pip的第一行改成了

#!/usr/local/bin/python

问题解决了

最佳答案

您可能需要brew link python,或者unlink 然后link 来让事情指向正确的地方。

关于python - 无法使用 OS X El Capitan pip 安装任何东西,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33313986/

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