在OSX 10.11(El Capitan)中安装Scrapy(系统完整性保护)时,出现“ OSError:[Errno 1] Operation not allow”

问题:在OSX 10.11(El Capitan)中安装Scrapy(系统完整性保护)时,出现“ OSError:[Errno 1] Operation not allow”

我正在尝试通过pip在OSX 10.11(El Capitan)中安装Scrapy Python框架。安装脚本下载所需的模块,并在某些时候返回以下错误:

OSError: [Errno 1] Operation not permitted: '/tmp/pip-nIfswi-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'

我尝试使用以下命令停用OSX 10.11中的无根功能:

sudo nvram boot-args="rootless=0";sudo reboot

但是当机器重启时,我仍然收到相同的错误。

我的StackExchangers同事有什么线索或想法吗?

如果有帮助,则完整的脚本输出如下:

sudo -s pip install scrapy
Collecting scrapy
  Downloading Scrapy-1.0.2-py2-none-any.whl (290kB)
    100% |████████████████████████████████| 290kB 345kB/s 
Requirement already satisfied (use --upgrade to upgrade): cssselect>=0.9 in /Library/Python/2.7/site-packages (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): queuelib in /Library/Python/2.7/site-packages (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): pyOpenSSL in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from scrapy)
Collecting w3lib>=1.8.0 (from scrapy)
  Downloading w3lib-1.12.0-py2.py3-none-any.whl
Collecting lxml (from scrapy)
  Downloading lxml-3.4.4.tar.gz (3.5MB)
    100% |████████████████████████████████| 3.5MB 112kB/s 
Collecting Twisted>=10.0.0 (from scrapy)
  Downloading Twisted-15.3.0.tar.bz2 (4.4MB)
    100% |████████████████████████████████| 4.4MB 94kB/s 
Collecting six>=1.5.2 (from scrapy)
  Downloading six-1.9.0-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): zope.interface>=3.6.0 in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from Twisted>=10.0.0->scrapy)
Requirement already satisfied (use --upgrade to upgrade): setuptools in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from zope.interface>=3.6.0->Twisted>=10.0.0->scrapy)
Installing collected packages: six, w3lib, lxml, Twisted, scrapy
  Found existing installation: six 1.4.1
    DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
    Uninstalling six-1.4.1:
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/basecommand.py", line 223, in main
status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/commands/install.py", line 299, in run
root=options.root_path,
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_set.py", line 640, in install
requirement.uninstall(auto_confirm=True)
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_install.py", line 726, in uninstall
paths_to_remove.remove(auto_confirm)
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_uninstall.py", line 125, in remove
renames(path, new_path)
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/utils/__init__.py", line 314, in renames
shutil.move(old, new)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
copy2(src, real_dst)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2
copystat(src, dst)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat
os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: '/tmp/pip-nIfswi-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'

I’m trying to install Scrapy Python framework in OSX 10.11 (El Capitan) via pip. The installation script downloads the required modules and at some point returns the following error:

OSError: [Errno 1] Operation not permitted: '/tmp/pip-nIfswi-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'

I’ve tried to deactivate the rootless feature in OSX 10.11 with the command:

sudo nvram boot-args="rootless=0";sudo reboot

but I still get the same error when the machine reboots.

Any clue or idea from my fellow StackExchangers?

If it helps, the full script output is the following:

sudo -s pip install scrapy
Collecting scrapy
  Downloading Scrapy-1.0.2-py2-none-any.whl (290kB)
    100% |████████████████████████████████| 290kB 345kB/s 
Requirement already satisfied (use --upgrade to upgrade): cssselect>=0.9 in /Library/Python/2.7/site-packages (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): queuelib in /Library/Python/2.7/site-packages (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): pyOpenSSL in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from scrapy)
Collecting w3lib>=1.8.0 (from scrapy)
  Downloading w3lib-1.12.0-py2.py3-none-any.whl
Collecting lxml (from scrapy)
  Downloading lxml-3.4.4.tar.gz (3.5MB)
    100% |████████████████████████████████| 3.5MB 112kB/s 
Collecting Twisted>=10.0.0 (from scrapy)
  Downloading Twisted-15.3.0.tar.bz2 (4.4MB)
    100% |████████████████████████████████| 4.4MB 94kB/s 
Collecting six>=1.5.2 (from scrapy)
  Downloading six-1.9.0-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): zope.interface>=3.6.0 in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from Twisted>=10.0.0->scrapy)
Requirement already satisfied (use --upgrade to upgrade): setuptools in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from zope.interface>=3.6.0->Twisted>=10.0.0->scrapy)
Installing collected packages: six, w3lib, lxml, Twisted, scrapy
  Found existing installation: six 1.4.1
    DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
    Uninstalling six-1.4.1:
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/basecommand.py", line 223, in main
status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/commands/install.py", line 299, in run
root=options.root_path,
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_set.py", line 640, in install
requirement.uninstall(auto_confirm=True)
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_install.py", line 726, in uninstall
paths_to_remove.remove(auto_confirm)
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_uninstall.py", line 125, in remove
renames(path, new_path)
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/utils/__init__.py", line 314, in renames
shutil.move(old, new)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
copy2(src, real_dst)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2
copystat(src, dst)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat
os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: '/tmp/pip-nIfswi-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'

回答 0

我也认为完全没有必要开始入侵OSX。

我能够解决它

brew install python

看来,使用新版El Capitan随附的python / pip会有一些问题。

I also think it’s absolutely not necessary to start hacking OS X.

I was able to solve it doing a

brew install python

It seems that using the python / pip that comes with new El Capitan has some issues.


回答 1

pip install --ignore-installed six

会做到的。

资料来源:github.com/pypa/pip/issues/3165

pip install --ignore-installed six

Would do the trick.

Source: github.com/pypa/pip/issues/3165


回答 2

正如其他答案所说,这是由于新的系统完整性保护,但我认为其他答案过于复杂。

如果您只想在当前用户中使用该软件包,则可以使用该--user标志,而无需禁用SIP,就可以很好地安装它。像这样:

sudo pip install --user packagename

As the other answers said, it’s because of the new System Integrity Protection, but I believe the other answers are overcomplicated.

If you’re only gonna use that package in the current user, you should be able to install it just fine, without the need to disable the SIP, by using the --user flag. Like this:

sudo pip install --user packagename

回答 3

高投票答案对我不起作用,似乎对El Capitan用户有效。但是对于MacOS Sierra用户,请尝试以下步骤

  1. brew install python
  2. sudo pip install --user <package name>

The high voted answers didn’t work for me, it seems to work for El Capitan users. But for MacOS Sierra users try the following steps

  1. brew install python
  2. sudo pip install --user <package name>

回答 4

警告事项

强烈建议不要在Mac上修改系统Python;可能会发生许多问题。

您的特定错误表明安装程序存在解决Scrapy依赖关系的问题,而不影响当前的Python安装。该系统使用Python执行许多基本任务,因此保持系统安装的稳定性和Apple最初安装的位置非常重要

在绕过内置安全性之前,我还将穷尽所有其他可能性

包管理器解决方案:

请先研究Python虚拟化工具,例如virtualenv;这样可以安全地进行实验。

在不与Mac OS冲突的情况下使用语言和软件的另一个有用工具是Homebrew。与MacPortsFink一样Homebrew是Mac的软件包管理器。,对于安全尝试许多其他语言和工具很有用。

“自行运行”软件安装:

如果您不喜欢包管理器方法,则可以使用该/usr/local路径或创建/opt/local用于安装备用Python安装的目录,然后在中修复路径.bashrc。请注意,您必须为这些解决方案启用root。

无论如何如何:

如果您绝对必须禁用安全检查(并且我衷心希望它用于解决系统语言和资源之外的其他问题),则可以暂时禁用它,然后使用本文中有关如何禁用系统的一些技术来重新启用它完整性保护

Warnings

I would suggest very strongly against modifying the system Python on Mac; there are numerous issues that can occur.

Your particular error shows that the installer has issues resolving the dependencies for Scrapy without impacting the current Python installation. The system uses Python for a number of essential tasks, so it’s important to keep the system installation stable and as originally installed by Apple.

I would also exhaust all other possibilities before bypassing built in security.

Package Manager Solutions:

Please look into a Python virtualization tool such as virtualenv first; this will allow you to experiment safely.

Another useful tool to use languages and software without conflicting with your Mac OS is Homebrew. Like MacPorts or Fink, Homebrew is a package manager for Mac, and is useful for safely trying lots of other languages and tools.

“Roll your own” Software Installs:

If you don’t like the package manager approach, you could use the /usr/local path or create an /opt/local directory for installing an alternate Python installation and fix up your paths in your .bashrc. Note that you’ll have to enable root for these solutions.

How to do it anyway:

If you absolutely must disable the security check (and I sincerely hope it’s for something other than messing with the system languages and resources), you can disable it temporarily and re-enable it using some of the techniques in this post on how to Disable System Integrity-Protection.


回答 5

这对我有用:

   sudo pip install scrapy --ignore-installed six

This did the trick for me:

   sudo pip install scrapy --ignore-installed six

回答 6

您应禁用“系统完整性保护”,这是El Capitan的一项新功能。

首先,您应该在终端上运行无根配置命令

# nvram boot-args="rootless=0"
# reboot

然后,您应该在恢复分区的终端(恢复操作系统)上运行以下命令

# csrutil disable
# reboot

我刚刚解决了我的问题。我不确定第一部分是否必要。随便尝试。

– 警告

一切正常后,您应该再次启用SIP。

只需再次重新启动进入恢复模式并在终端中运行

# csrutil enable

csrutil:配置系统完整性保护

You should disable “System Integrity Protection” which is a new feature in El Capitan.

First, you should run the command for rootless config on your terminal

# nvram boot-args="rootless=0"
# reboot

Then, you should run the command below on recovery partition’s terminal (Recovery OS)

# csrutil disable
# reboot

I’ve just solved my problem like that. I’m not sure that the first part is necessary. Try as you like.

–WARNING

You should enable SIP again after everything works;

Simply reboot again into Recovery Mode and run in terminal

# csrutil enable

csrutil: Configuring System Integrity Protection


回答 7

我试图通过El Capitan中的pip安装AWS,但出现此错误

OSError:[Errno 1]不允许操作:’/var/folders/wm/jhnj0g_s16gb36y8kwvrgm7h0000gp/T/pip-wTnb_D-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six- 1.4.1-py2.7.egg-info’

我在这里找到答案

sudo -H pip install awscli --upgrade --ignore-installed six

这个对我有用 :)

I tried to install AWS via pip in El Capitan but this error appear

OSError: [Errno 1] Operation not permitted: ‘/var/folders/wm/jhnj0g_s16gb36y8kwvrgm7h0000gp/T/pip-wTnb_D-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info’

I found the answer here

sudo -H pip install awscli --upgrade --ignore-installed six

It works for me :)


回答 8

我在MacOS Sierra上遇到了相同的错误。我按照以下步骤操作,成功安装了可伸缩的软件包。

1. sudo pip install --ignore-installed six
2. sudo pip install --ignore-installed scrapy

MacBook-Air:~ shree$ scrapy version
Scrapy 1.4.0

I was getting the same error on on my MacOS Sierra. I followed these steps and successfully able to install scarpy package.

1. sudo pip install --ignore-installed six
2. sudo pip install --ignore-installed scrapy

MacBook-Air:~ shree$ scrapy version
Scrapy 1.4.0

回答 9

这对我有用。

sudo pip install –ignore-installed scrapy

This did the trick for me.

sudo pip install –ignore-installed scrapy


回答 10

尝试了一些答案的组合,最终成功了:

sudo -H pip install --upgrade --ignore-installed awsebcli

干杯

Tried a combination of some answers and this eventually worked:

sudo -H pip install --upgrade --ignore-installed awsebcli

Cheers


回答 11

再次安装python:

brew安装python

再试一次:

须藤点安装刮

为我工作,希望它可以帮助

install python again:

brew install python

try it again:

sudo pip install scrapy

works for me, hope it can help


回答 12

重新启动Mac->在启动提示音后按住“ Command + R”->打开OS X实用程序->打开终端并键入“ csrutil disable”->重新启动OS X->打开终端并检查“ csrutil status”

Restart Mac -> hold down “Command + R” after the startup chime -> Opens OS X Utilities -> Open Terminal and type “csrutil disable” -> Reboot OS X -> Open Terminal and check “csrutil status”


回答 13

这个命令可以很好地工作:D

sudo -H pip install –upgrade package_name –ignore-installed六

This command would work perfectly fine :D

sudo -H pip install –upgrade package_name –ignore-installed six


回答 14

如果您尝试使用pip而不是pip3在python2文件夹中安装python3 lib,有时可能会实现这种行为。

Sometimes such behavior may be achieved if you try to install python3 lib in python2 folder using pip instead of pip3.


回答 15

  1. -关闭SIP(系统完整性保护)-然后重新启动,使用命令+ R进入调试模式,然后选择终端:csrutil disable reboot

2。

sudo C_INCLUDE_PATH = /应用程序/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libxml2:/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX .platform / Developer / SDKs / MacOSX10.11.sdk / usr / include / libxml2 / libxml:/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/包括pip install scrapy –ignore-installed 6

3.-然后删除旧的六个,重新安装sudo rm -rf /Library/Python/2.7/site-packages/six* sudo rm -rf /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/ lib / python / six * sudo pip安装六

4.-然后将其设置回csrutil启用重新启动

-cr脚的作品现在

  1. — close SIP(system Integrity Protection) — then reboot, use command +R to enter debug mode, then select terminal: csrutil disable reboot

2.

sudo C_INCLUDE_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libxml2 :/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libxml2/libxml :/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include pip install scrapy –ignore-installed six

3. — then remove old six, install it again sudo rm -rf /Library/Python/2.7/site-packages/six* sudo rm -rf /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six* sudo pip install six

4. — then set it back csrutil enable reboot

— crappy works now


回答 16

它对我有用:

pip install scrapy --user -U

it work for me:

pip install scrapy --user -U

回答 17

我在其他地方缺少依赖项,因此我为项目安装了其他要求,如下所示:

pip install --user -r requirements.txt

I was missing a dependency somewhere else along the line, so I installed the other requirements for the project like this:

pip install --user -r requirements.txt