Mac OS X El Capitan (10.11) sudo pip install 報錯 “OSError: [Errno 1] Operation not permitted”

來源:互聯網
上載者:User

標籤:

由於 OS X El Capitan 採用了 System Integrity Protection 保護技術,導致 sudo pip install 安裝python包時會產生報錯:

1   File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 150, in makedirs2     makedirs(head, mode)3   File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs4     mkdir(name, mode)5 OSError: [Errno 1] Operation not permitted: ‘/System/Library/Frameworks/Python.framework/Versions/2.7/selenium‘

SIP 相關命令 csrutil:

 1 xx:~ $ csrutil 2 usage: csrutil <command> 3 Modify the System Integrity Protection configuration. All configuration changes apply to the entire machine. 4 Available commands: 5  6     clear 7         Clear the existing configuration. Only available in Recovery OS. 8     disable 9         Disable the protection on the machine. Only available in Recovery OS.10     enable11         Enable the protection on the machine. Only available in Recovery OS.12     status13         Display the current configuration.14 15     netboot16         add <address>17             Insert a new IPv4 address in the list of allowed NetBoot sources.18         list19             Print the list of allowed NetBoot sources.20         remove <address>21             Remove an IPv4 address from the list of allowed NetBoot sources.

查看當前SIP狀態:

1 xx:~ $ csrutil status2 System Integrity Protection status: enabled.

受到SIP保護的路徑:

  • /System
  • /usr
  • /bin
  • /sbin
  • OS X 預裝的應用

 

如果需要全域安裝python包,則需要先關閉SIP,具體方法如下:

1、重啟系統,重啟過程中按住option然後選擇恢複分區

2、進入恢複系統後點擊菜單“工具 + 生產力”,開啟終端,輸入csrutil disable

3、正常重啟

4、sudo pip install xx包

5、安裝完畢後建議進入恢複分區通過終端開啟SIP: csrutil enable

 

另外建議:關閉SIP後安裝virtualenv,然後開啟SIP,後續通過virtualenv進行環境管理。

 

參考連結:

http://stackoverflow.com/questions/33004708/osx-el-capitan-sudo-pip-install-oserror-errno-1-operation-not-permitted

http://www.cnblogs.com/xiongqiangcs/p/4914049.html

https://support.apple.com/en-us/HT204899

 

Mac OS X El Capitan (10.11) sudo pip install 報錯 “OSError: [Errno 1] Operation not permitted”

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.