OSX El Capitan: sudo pip install OSerror: [ Errno: 1]操作不允许

当我跑步的时候:

sudo pip install ipython

我得到以下错误

错误: [错误号: 1]操作不允许: “/系统/库/框架/Python 框架/版本/2.7/共享”

最后执行的命令尝试创建上面给出的目录。

此外,下面的命令未能安装 iPython 而没有提供任何错误。

sudo pip install --user python

(我使用的是 Mac OS X El Capitan,以防这个操作系统上的其他人看到同样的问题。)

128837 次浏览

我完全同意米科的观点,但如果你还想这么做,这样做:

  • 在恢复模式下重新启动(保持 cmd + R)
  • 从公共设施打开终端
  • 使用命令 csrutil disable

pip3 install <package>代替,用 pip解决了权限问题。

我有同样的问题,但使用 easy_install "module"为我解决了这个问题。

我不知道为什么,但 pipeasy_install使用不同的安装位置,和 easy_install选择正确的。

编辑: 没有重新检查,但因为注释; 似乎不同的(OSX 和酿造安装)安装互相干扰,这就是为什么提到的工具指向不同的位置(因为他们属于不同的安装)。我知道通常这些工具从一个安装点到同一个文件夹。

你应该重新安装 Python:

brew reinstall python

要得到酿造看到 冲泡主页

我也有同样的问题。 正如其他人所提到的,不要用 sudo 运行 pip install。 快跑

brew doctor

并修复警告,您应该能够继续您的 pip 安装。

很难让 Pip 在酋长岩工作,原因有以下几点:

  1. OS X 没有正确设置一些 distutils 变量,因此 pip 尝试在 /System/Library/下的位置安装辅助文件。El Capitan 阻止了这个,这就是你正在遇到的错误。
  2. OS X 在 /System/Library/下包含了一些过时的软件包。皮普经常想升级这些,但不能在埃尔卡皮坦。
  3. OS X 在 Python 搜索顺序中将 /System/Library/放在比 /Library/Python/2.7/site-packages(系统范围内的 python 包位置)更高的位置,因此即使您设法安装了一些包的新版本,旧版本仍然会被加载,打破了一些依赖关系。

https://apple.stackexchange.com/a/223163/143849上有解决所有这些问题的方法。但是您最好通过标准的 Python 安装程序 Homebrew 或 Anaconda 来安装自己版本的 Python。

我猜你和其他包裹有冲突。对我来说是 six。所以你需要像这样使用一个命令:

pip install google-api-python-client --upgrade --ignore-installed six

或者

pip install --ignore-installed six

pip install --ignore-installed six

这样就可以了,然后你可以尝试你的第一个命令。

通过 http://github.com/pypa/pip/issues/3165

同样的错误

Installing collected packages: six, pyparsing, packaging, appdirs, setuptools
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 784, in install
**kwargs
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 345, in move_wheel_files
clobber(source, lib_dir, True)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 323, in clobber
shutil.copyfile(srcfile, destfile)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 83, in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/six.py'

这里我使用没有 sudo--user来解决这个问题

$ pip install --user scikit-image h5py keras pygame
Collecting scikit-image
Downloading http://mirrors.aliyun.com/pypi/packages/65/69/27a1d55ce8f77c8ac757938707105b1070ff4f2ae47d2dc99461bfae4491/scikit_image-0.13.0-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (28.1MB)
100% |████████████████████████████████| 28.1MB 380kB/s
Collecting h5py
Downloading http://mirrors.aliyun.com/pypi/packages/b7/cc/1c29b0815b12de2c92b5323cad60f724ac8f0e39d0166d0b9dfacbcb70dd/h5py-2.7.0-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (4.5MB)
100% |████████████████████████████████| 4.5MB 503kB/s
Requirement already satisfied: keras in /Library/Python/2.7/site-packages
Requirement already satisfied: pygame in /Library/Python/2.7/site-packages
Requirement already satisfied: matplotlib>=1.3.1 in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from scikit-image)
Requirement already satisfied: six>=1.7.3 in /Library/Python/2.7/site-packages (from scikit-image)
Requirement already satisfied: pillow>=2.1.0 in /Library/Python/2.7/site-packages (from scikit-image)
Requirement already satisfied: networkx>=1.8 in /Library/Python/2.7/site-packages (from scikit-image)
Requirement already satisfied: PyWavelets>=0.4.0 in /Library/Python/2.7/site-packages (from scikit-image)
Collecting scipy>=0.17.0 (from scikit-image)
Downloading http://mirrors.aliyun.com/pypi/packages/72/eb/d398b9f63ee936575edc62520477d6c2353ed013bacd656bd0c8bc1d0fa7/scipy-0.19.0-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (16.2MB)
100% |████████████████████████████████| 16.2MB 990kB/s
Requirement already satisfied: numpy>=1.7 in /Library/Python/2.7/site-packages (from h5py)
Requirement already satisfied: theano in /Library/Python/2.7/site-packages (from keras)
Requirement already satisfied: pyyaml in /Library/Python/2.7/site-packages (from keras)
Requirement already satisfied: python-dateutil in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from matplotlib>=1.3.1->scikit-image)
Requirement already satisfied: tornado in /Library/Python/2.7/site-packages (from matplotlib>=1.3.1->scikit-image)
Requirement already satisfied: pyparsing>=1.5.6 in /Users/qiuwei/Library/Python/2.7/lib/python/site-packages (from matplotlib>=1.3.1->scikit-image)
Requirement already satisfied: nose in /Library/Python/2.7/site-packages (from matplotlib>=1.3.1->scikit-image)
Requirement already satisfied: olefile in /Library/Python/2.7/site-packages (from pillow>=2.1.0->scikit-image)
Requirement already satisfied: decorator>=3.4.0 in /Library/Python/2.7/site-packages (from networkx>=1.8->scikit-image)
Requirement already satisfied: singledispatch in /Library/Python/2.7/site-packages (from tornado->matplotlib>=1.3.1->scikit-image)
Requirement already satisfied: certifi in /Library/Python/2.7/site-packages (from tornado->matplotlib>=1.3.1->scikit-image)
Requirement already satisfied: backports_abc>=0.4 in /Library/Python/2.7/site-packages (from tornado->matplotlib>=1.3.1->scikit-image)
Installing collected packages: scipy, scikit-image, h5py
Successfully installed h5py-2.7.0 scikit-image-0.13.0 scipy-0.19.0

希望对遇到类似问题的人有所帮助!

我已经通过 brew 安装了 python2.7,下面的代码解决了我的问题

brew install numpy

它安装 python3,但是它仍然可以工作,并且将它设置为2.7。

DR $PATH 修复

  1. 使用 pip install --user package_name安装应该包含 CLI 可执行文件的包。
  2. 启动一个 python shell 和 import package_name
  3. 查找输出中 lib/python/...出现的位置,并将其全部替换为 bin
  4. 很可能是 $HOME/Library/Python/2.7/bin

细节

由于 MacOS 10.11 El Capitan 中新的系统完整性保护,您不能再使用 sudo pip install。我们在这里不讨论这个问题的好处。

另一个答案解释说,你应该 pip install --user,这是正确的。但是他们把你送到后面的小巷里去弄清楚如何处理你的 $PATH,这样你就可以访问已经安装好的可执行文件了。幸运的是,我已经破解了一个 对不相关问题的相似需求

这是我如何在我的一个系统上解决这个问题的文字记录。我把它们都包括在内,而不是仅仅包括我使用的 $PATH,因为你的系统可能和我的不同。这个过程应该对每个人都有效。

$ pip install --user jp
Collecting jp
Downloading jp-0.2.4.tar.gz
Installing collected packages: jp
Running setup.py install for jp ... done
Successfully installed jp-0.2.4


$ python -c 'import jp; print jp'
<module 'jp' from '/Users/bbronosky/Library/Python/2.7/lib/python/site-packages/jp/__init__.pyc'>


$ find /Users/bbronosky/Library/Python -type f -perm -100
/Users/bbronosky/Library/Python/2.7/bin/jp


$ which jp


$ echo -e '\n''export PATH=$HOME/Library/Python/2.7/bin:$PATH' >> ~/.bashrc


$ bash # starting a new bash process for demo, but you should open a new terminal


$ which jp
/Users/bbronosky/Library/Python/2.7/bin/jp


$ jp
usage: jp <expression> <filepath>