OSX El Capitan:sudo pip install OSError:[Errno:1]不允许操作 [英] OSX El Capitan: sudo pip install OSError: [Errno: 1] Operation not permitted

查看:211
本文介绍了OSX El Capitan:sudo pip install OSError:[Errno:1]不允许操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我跑步时:

sudo pip install ipython

我收到以下错误


OSError:[Errno:1]操作不是允许:'/System/Library/Frameworks/Python.framework/Versions/2.7/share'

OSError: [Errno: 1] Operation not permitted: '/System/Library/Frameworks/Python.framework/Versions/2.7/share'

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

The last command executed tries to create the directory given above.

此外,以下命令无法在不提供任何错误的情况下安装iPython。

Also, the following command fails to install iPython without providing any errors.

sudo pip install --user python

(我在Mac OS上) X El Capitan以防其他人在此操作系统上看到同样的问题。)

(I am on Mac OS X El Capitan in case other folks on this OS see the same issue.)

推荐答案

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

如果有任何教程说你应该做 sudo pip 然后请提交针对此软件包的错误。作者正在教育Python社区,因为时间已经证明 sudo pip 是一种破碎的做法。

If there is any tutorial out there which says you should do sudo pip then please file a bug against this package. The author is dis-educating Python community, as time has proven sudo pip to be a broken practice.

< a href =http://www.infoworld.com/article/2988096/mac-os-x/sorry-unix-fans-os-x-el-capitan-kills-root.html\"rel =noreferrer> OSX El Capitan引入了一种防止破坏操作系统文件的机制。 /System/Library/Frameworks/Python.framework/Versions/2.7/share 是受保护的位置之一。 普通用户没有理由在那里放置或写入任何文件。这是因为操作系统本身依赖于这些文件而且 sudo pip ,从上面给出的所有力量都将无条件地覆盖它们。通常不会发生坏事,但有可能存在。 Apple希望保护他们的操作系统用户不小心搞砸他们的安装。

OSX El Capitan introduced a mechanisms to prevent damaging the operating system files. /System/Library/Frameworks/Python.framework/Versions/2.7/share is one of the protected locations. A normal user has no reason to put or write any files there. This is because the operating system itself relies on these files and sudo pip, with all force given from the above, would unconditionally overwrite them. Usually bad things would not happen, but the chances are there. Apple wants to protect their OS users to accidentally bricking their installation.

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

Instead, you need to install a Python package, like IPython, locally to the home folder of your user. The easiest way is to create a virtual environment, activate it and then run pip in the virtual environment.

示例:

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

更多信息

如何创建虚拟环境

或者,一个人应该能够 pip install --user 。但同样,不需要sudo ,您需要手动设置 PATH 环境变量。

Alternatively, one should be able to do pip install --user. But again, no sudo needed and you need to manually set up PATH environment variable.

这篇关于OSX El Capitan:sudo pip install OSError:[Errno:1]不允许操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆