OSX埃尔卡皮坦:须藤PIP安装OSERROR:[错误:1]操作不允许

问题描述 投票:125回答:16

当我运行:

sudo pip install ipython

我得到以下错误

OSERROR:[错误:1]操作不允许: '/System/Library/Frameworks/Python.framework/Versions/2.7/share'

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

此外,下面的命令失败,而不提供任何错误安装IPython的。

sudo pip install --user python

(我在Mac OS X埃尔卡皮坦的情况下,此操作系统其他人看到了同样的问题。)

pip ipython failed-installation osx-elcapitan
16个回答
202
投票

说明,告知sudo pip install本质上是错误的。

如果有任何教程在那里它说你应该做的,然后sudo pip请提交一个bug针对这个包。作者是DIS-教育Python社区,随着时间的证明sudo pip是一个破碎的做法。

OSX El Capitan introduced a mechanisms to prevent damaging the operating system files/System/Library/Frameworks/Python.framework/Versions/2.7/share是受保护的地点之一。普通用户没有理由把或写入任何文件存在。这是因为操作系统本身依赖于这些文件和sudo pip,从上面给出的全部力量,将无条件覆盖它们。通常不好的事情不会发生,但机会的存在。苹果希望保护他们的OS用户意外砌体它们的安装。

相反,你需要安装一个Python包,像IPython中,对本地用户的主文件夹。最简单的方法是创建一个虚拟环境,激活它,然后在虚拟环境中运行点子。

例:

cd ~  # Go to home directory
virtualenv my-venv
source my-venv/bin/activate
pip install IPython

更多信息

另外,应该能够做到pip install --user。但同样,没有sudo的需要,你需要手动设置PATH环境变量。


4
投票

我猜你有其他包装有些冲突。对我来说是six。所以,你需要使用如下命令:

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

要么

pip install --ignore-installed six


1
投票

我与米克完全同意,但如果你仍然想这样做,这里是这样的:

  • 重新启动以恢复模式(保持CMD + R)
  • 从实用程序开放端子
  • 使用命令csrutil disable

0
投票

我已经通过python2.7酿造安装和下列解决我的问题

BREW安装numpy的

它安装python3,但它仍然有效,并设置它为2.7为好。


24
投票

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

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

编辑:没有重新检查,但因为意见的;似乎不同(OSX和BREW安装)安装相互干扰这就是为什么他们的工具确实被提及的点不同的位置(因为它们属于不同的安装)。据我所知,通常是从一个这些工具安装指向同一个文件夹中。


18
投票

您应该重新安装的Python:

brew reinstall python

要获得BREW看到brew homepage


15
投票

pip install --ignore-installed six

这将做的工作,那么你可以尝试你的第一个命令。

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


11
投票

使用pip3 install <package>而是与pip解决了权限问题。


10
投票

TL;DR $PATH fix

  1. 使用pip install --user package_name安装包,应包括CLI可执行文件。
  2. 启动一个python壳和import package_name
  3. 寻找到lib/python/...在输出时,用bin更换所有
  4. 这很可能是$HOME/Library/Python/2.7/bin

Details

因为新的系统完整性保护的MacOS 10.11埃尔卡皮坦,你可以不再sudo pip install。我们不会在这里讨论的是优点。

另一个答案解释说,你应该pip install --user这是正确的。但是他们送你到后巷弄清楚怎么做你$PATH,这样你可以得到访问安装的可执行文件。幸运的是,我已经解决了similar need for an unrelated question

下面是我如何解决我的系统的一个问题成绩单。我包括这一切,而不是为我工作的$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>

10
投票

同样的错误

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'

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

$ 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 

希望这将帮助别人谁遇到类似的问题!


9
投票

我有同样的问题。正如其他人所说,不跑PIP使用sudo安装。跑

brew doctor 

并修复警告,你应该能够与你的点子安装继续进行。


6
投票

要获得埃尔卡皮坦PIP工作有以下几个原因这是很难:

  1. OS X没有正确设置一些distutils的变量,所以PIP尝试下/System/Library/地点安装辅助文件。埃尔卡皮坦块这一点,这是你碰到的错误。
  2. OS X包括一些按/System/Library/过时的包。 PIP经常要升级这些,但可以在埃尔卡皮坦没有。
  3. /System/Library//Library/Python/2.7/site-packages(全系统的Python包的位置)蟒蛇搜索顺序高,所以即使你设法安装一些软件包的更新版本,旧的依然得到加载,打破一些依赖OS X的地方。

有变通方法为所有这些在https://apple.stackexchange.com/a/223163/143849。但是你可能是最好关闭通过标准的Python安装程序,自制或蟒蛇安装自己的Python版本。

© www.soinside.com 2019 - 2024. All rights reserved.