Mac OSX python 安装pandas numpy scrapy的问题

xiaoxiao2021-02-28  14

OSX 使用 pip 来安装pandas的时候,发现安装不了,会报以下的错误:

[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' Google了下,发现是由于之前XCode编译器代码被注入的事件之后,OSX EI Capitan系统升级,启用了系统完整性保护 System Integrity Protection,也就是SIP。这样,系统的文件添加了强制性的保护措施,不允许直接操作系统的文件。

Apple官方的解释如下:

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

那么,只要关闭SIP后,是否就可以正常安装了呢?尝试一下。

点击Mac电脑的苹果图标  选择 重新启动  按住 command+R,直到进入还原模式  选择实用工具,然后点击 终端  输入 csrutil disable 按下回车  重启电脑  这样就将“SIP“关闭了。

这时候,再来安装pandas就可以了。

安装完pandas后,在使用时,发现需要更新numpy,系统自带的版本是1.8.0,执行 pip install -U numpy,安装成功。

但是,又出现了新的问题,在使用时,提示numpy版本不对!

ImportError: this version of pandas is incompatible with numpy < 1.9.0 your numpy version is 1.8.0rc1. Please upgrade numpy to >= 1.9.0 to use this pandas version

可是命名已经更新到1.13.3版本了呀,这是什么情况?

于是查看了下OSX 自带的python lib包,发现了问题

>>> import numpy >>> print numpy.__version__ 1.8.0rc1 >>> print(numpy) <module 'numpy' from '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/__init__.pyc'> 由于numpy的包,在系统中是已经存在了一份,而安装pandas时更新numpy的包,使用的是另外一份,于是只需要把原系统中残留的包删掉就好了。 >>> import numpy >>> print numpy.__version__ 1.13.3

不巧,在使用Scrapy时,又报错

AttributeError: 'module' object has no attribute 'OP_NO_TLSv1_1' 原因是Twisted版本与Scrapy的版本不符,向下更新一下Twisted就好

pip install twisted==13.1.0

转载请注明原文地址: https://www.6miu.com/read-2050157.html

最新回复(0)