可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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:
回答1:
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.
回答2:
pip install --ignore-installed six
Would do the trick.
Source: github.com/pypa/pip/issues/3165
回答3:
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
回答4:
The high voted answers didn't work for me, it seems to work for EI Capitan users. But for MacOS Sierra users try the following steps
brew install python sudo pip install --user
回答5:
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.
回答6:
This did the trick for me:
sudo pip install scrapy --ignore-installed six
回答7:
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
回答8:
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 :)
回答9:
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
回答10:
This did the trick for me.
sudo pip install --ignore-installed scrapy
回答11:
install python again:
brew install python
try it again:
sudo pip install scrapy
works for me, hope it can help
回答12:
Tried a combination of some answers and this eventually worked:
sudo -H pip install --upgrade --ignore-installed awsebcli
Cheers
回答13:
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"
回答14:
This command would work perfectly fine :D
sudo -H pip install --upgrade package_name --ignore-installed six
回答15:
Sometimes such behavior may be achieved if you try to install python3 lib in python2 folder using pip instead of pip3.
回答16:
- -- 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
回答17:
it work for me:
pip install scrapy --user -U
回答18:
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