1. 程式人生 > >Mac系統10.11及以上升級numpy、scipy等python包報錯解決方案

Mac系統10.11及以上升級numpy、scipy等python包報錯解決方案

最近看到引力波相關內容,其中關於科學家們使用了一個python的第三方包:GWPY包。好奇之下,自己也安裝了一下這個python包。但是發現一個問題。Mac系統自帶的python無法更新第三方包,其中報錯的是numpy包,錯誤如下:

Collecting numpy

Using cached numpy-1.10.2-cp27-none-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whlInstalling
 collected packages: numpy
 Found existing installation: numpy 1.8
.0rc1 DEPRECATION: Uninstalling a distutils installed project (numpy) 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 numpy-1.8.0rc1:Exception:Traceback (most recent call last
): File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/basecommand.py", line 211, in main status = self.run(options, args) File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/commands/install.py", line 311, in run root=options.root_path, File "/Library/Python/2.7/site-packages/pip-7.1.2-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.2-py2.7.egg/pip/req/req_install.py", line 716, in uninstall paths_to_remove.remove(auto_confirm) File "/Library/Python/2.7/site-packages/pip-7.1.2-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.2-py2.7.egg/pip/utils/__init__.py", line 315, 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: '/var/folders/5n/vbm997m56xg3kw67y6bccn2m0000gn/T/pip-4tcBsd-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info'

使用pip 重新安裝 numpy 包

pip install -U numpy

依然報錯,錯誤輸出的內容和上面的一致。

冷靜下來後重新看了一些錯,Operation not permitted 沒有操作許可權。奇怪了,系統在10.9和10.10的時候都沒有出現這種情況,難道是蘋果自己搞的鬼?

自己無法解決,只好求助於“度娘“ 和谷歌,不懈努力後還真的發現了問題。

經歷了XCode編譯器程式碼被注入的事件後,這次 Mac OS X El Capitan系統的升級,啟用了更高的安全性保護機制:系統完整性保護System Integrity Protection (SIP)。簡單來講就是更加強制性的保護系統相關的資料夾。開發者不能直接操作相關的檔案內容。

蘋果官方的解釋
System Integrity Protection is a security technology in OS X El Capitan that’s designed to help prevent potentially malicious software from modifying protected files and folders on your Mac.
In OS X, the “root” user account previously had no permission restrictions and could access any system folder or application on your Mac. Software gained root-level access when you entered your administrator name and password to install it and could then modify or overwrite any system file or application.
System Integrity Protection restricts the root account and limits the actions that the root user can perform on protected parts of OS X.
Paths and applications protected by System Integrity Protection include:
/System
/usr
/bin
/sbin
Apps that are pre-installed with OS X
Paths and applications that third-party apps and installers can write to include:
/Applications
/Library
/usr/local
System Integrity Protection is designed to allow modifications of these protected parts only by processes that are signed by Apple and have special entitlements to write to system files, like Apple software updates and Apple installers.
Apps that you download from the Mac App Store already work with System Integrity Protection. Other third-party software that conflicts with System Integrity Protection might be set aside when you upgrade to OS X El Capitan.
System Integrity Protection also helps prevent software from changing your startup volume. To boot your Mac from a different volume, you can use the Startup Disk pane in System Preferences or you can hold down the Option key while you reboot, and select a volume from the list.
Information about products not manufactured by Apple, or independent websites not controlled or tested by Apple, is provided without recommendation or endorsement. Apple assumes no responsibility with regard to the selection, performance, or use of third-party websites or products. Apple makes no representations regarding third-party website accuracy or reliability. Risks are inherent in the use of the Internet. Contact the vendor for additional information. Other company and product names may be trademarks of their respective owners.
Last Modified: Oct 2, 2015
來源: https://support.apple.com/en-us/HT204899

找到問題的原因就可以解決相關的問題了,解決問題的方法就是關閉Mac系統的“SIP“。

具體的操作步驟,引用國外的一個牛人給出的方法:
How to turn off System Integrity Protection in El Capitan

  1. Click the  menu.
  2. Select Restart
  3. Hold down command-R to boot into the Recovery System.
  4. Click the Utilities menu and select Terminal.
  5. Type csrutil disable and press return .
  6. Close the Terminal app.
  7. Click the  menu and select Restart… .

好吧,照顧一下看不懂英語的朋友。

  1. 點選Mac電腦的蘋果圖示
  2. 選擇 重新啟動
  3. 按住 command+R,直到進入還原模式
  4. 選擇實用工具,然後點選 終端
  5. 輸入 csrutil disable 按下回車
  6. 重啟電腦

這樣就將“SIP“關閉了。

然後我們使用 pip 安裝升級numpy、scipy等相關的包。

問題是解決了,但是如果到這裡就認為已經萬事大吉了,其實是大錯特錯了。蘋果官方之所以設定“SIP“主要是考慮到系統的安全性問題。所以,我們最好還是將“SIP“開啟。開啟的方式如下:
1. 點選Mac電腦的蘋果圖示
2. 選擇 重新啟動
3. 按住 command+R,直到進入還原模式
4. 選擇實用工具,然後點選 終端
5. 輸入 csrutil enable 按下回車
6. 重啟電腦

萬事大吉,收工睡覺!

相關推薦

Mac系統10.11以上升級numpyscipypython解決方案

最近看到引力波相關內容,其中關於科學家們使用了一個python的第三方包:GWPY包。好奇之下,自己也安裝了一下這個python包。但是發現一個問題。Mac系統自帶的python無法更新第三方包,其中報錯的是numpy包,錯誤如下: Collecting

NumPySciPy Python在Windows下的whl安裝下載

感謝加利福尼亞大學爾灣分校(University of California, Irvine)熒光動力實驗室(瞎翻譯的,原名Laboratory for Fluorescence Dynamics,LFD)提供的便利,點選檢視下載。 該地址提供了許多開源擴充套

mac tar命令壓縮後上傳到windows虛擬機器解壓解決方案

  在解壓tar.gz檔案的時候報錯   [[email protected] Downloads]$ tar -zxvf clion-141.351.4.tar.gz   gzip: stdin: not in gzip format   tar: Child returned status

Mac系統10.11之後/usr/bin 不能拷貝進去class-dump該怎麼辦

借用大神的頭腦~~~ 第一步,開啟Terminal,輸入mkdir ~/bin,在當前使用者根目錄下建立一個bin目錄; 命令: mkdir ~/bin 第二步,把class-dump給拷貝到這個目錄裡,並賦予其可執行許可權; 命令一: mv /.../class-dump

Mac系統10.11(10.12)之後/usr/bin 不能拷貝進去class-dump該怎麼辦

最近在研究class-dump 反編譯軟體,發現安裝的時候有些問題. /us/bin 沒有許可權 . 但文件說明需要把class-dump檔案放進去 但是可以在~/.bash_profile 環境配置檔案下新增 “指引”路徑. 在終端下,新建一個資料夾把

python下的複雜網路程式設計networkxmatplotlibnumpy安裝解決方案

前言:python和matplotlib 、 numpy、networkx Python是一種解釋性語言(儘管是高度優化過的),和C或者Fortran相比,這類語言對很多重數值演算法來說執行緩

validators配置要點No result defined for action解決方案

result 文件 con 屬性 得到 驗證類型 name 命名 請求 在做JavaEE SSH項目時,接觸到validators驗證。 需要了解validators配置,或者遇到No result defined for action 這個錯誤時,可查閱本文得到有效解決

Mac 下 Chrome 瀏覽器 ERR_NETWORK_CHANGED 解決方案

chan 安全 方案 pan chrom remove 由於 pat net 一直以為是 SwitchyOmega 和 SpechtLite 的問題,原來是支付寶安全控件。 由於支付寶現在已經不需要 Mac 安全控件機制,所以可以通過在 terminal 運行以下命令來移

asp.net core 2.0釋出到IIS流程解決方案

  我這是個新裝的伺服器,沒有安裝任何軟體。 一、釋出流程 1.安裝AspNetCoreModule託管模組,同時會自動安裝..net core runtime DotNetCore.2.0.8-WindowsHosting.exe https://docs.microsoft.

Mac OS 使用PyCharm 啟動Python Django程式 解決方案

報錯資訊圖片 報錯資訊文字 django.core.exceptions.ImproperlyConfigured: Requested setting USE_I18N, but settings are not configured. You must either define

android studio升級到3.0.1後apt解決

1.現象描述 原來專案在Android studio 2.3一切正常,升級3.0之後報如下錯誤: Error:Cannot choose between the following configurations of project :android_sdk: - d

macpython安裝scrapy解決方案

distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse(‘incremental>=16.10.1’) Command “python setup.p

virtualBox安裝centos6增強解決配置共享資料夾

 一、安裝增強包 1、啟動CentOS6.5 虛擬機器,點選裝置à安裝增強功能。 則 “光碟”VBOXADDITIONS已經掛載到 CentOS 5.5 的桌面上了. 此時 雙擊光碟—>雙擊VboxLinuxAdditions.run即可完成安裝   通

基於Linux安裝Apache環境搭建過程解決方案

⁄(⁄ ⁄•⁄ω⁄•⁄ ⁄)⁄決定寫一篇完整的了!! 一、需要準備的安裝包: 二、上傳到Linux系統裡,tar -zxvf 解壓,再分別進入三個資料夾編譯 首先把三個壓縮包都傳入/usr/lo

ubuntu下如何安裝多版本的python之python3.6.1安裝numpyscipy依賴

  最近需要搭建Pytorch框架,復現某個工程,需要在python3.6版本下實現。由於ubuntu14.04系統預設安裝的是python2.7.6和python3.4版本,在這個地方被坑了無數次,主要是安裝了python後需要安裝python3.6的依賴包,

用pip安裝Pythonnumpyscipy資料分析類擴充套件庫

系統Win7(64位)Python版本:2.7.12 (64位)      在windows下安裝numpy、scipy等擴充套件庫的時候,通常有以下幾種辦法:用pip安裝(推薦);用easy_ins

Linux上安裝Apache環境安裝過程解決方案(零初始環境)

Note:要從零開始搭建,就不要嫌中間遇到各種eggache的問題! 一.下載apache原始碼    得到檔案 httpd-2.4.3.tar.gz 2. 上傳到你的伺服器目錄,如:/home/tnuser/installers     解壓:tar -zxv

MyBatis的4種引入對映器的方法,解決方案

1.用檔案路徑引入對映器 <mappers> <mapper resource="xxxMapper.xml"/> </mappers> 2.用包名引入對映器 <mappers> <pac

Mac跑GoLand解決方案

開發十年,就只剩下這套架構體系了! >>>   

ImportError: DLL load failed: 找不到指定的模塊;ImportError: numpy.core.multiarray failed to import 解決

nac gpe install core pat print imp sdn peter python程序運行出錯,出錯的兩行主要信息如下: ImportError: DLL load failed: 找不到指定的模塊 ImportError: numpy.core.m