具体报错
Found existing installation: setuptools 18.5
Uninstalling setuptools-18.5:
Could not install packages due to an EnvironmentError: [('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc', '/private/var/folders/st/r_c40wz94cnf4c426r0lvp600000gn/T/pip-uninstall-b9GLPD/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc', "[Errno 1] Operation not permitted: '/private/var/folders/st/r_c40wz94cnf4c426r0lvp600000gn/T/pip-uninstall-b9GLPD/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.py', '/private/var/folders/st/r_c40wz94cnf4c426r0lvp600000gn/T/pip-uninstall-b9GLPD/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.py', "[Errno 1] Operation not permitted: '/private/var/folders/st/r_c40wz94cnf4c426r0lvp600000gn/T/pip-uninstall-b9GLPD/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py', '/private/var/folders/st/r_c40wz94cnf4c426r0lvp600000gn/T/pip-uninstall-b9GLPD/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py', "[Errno 1] Operation not permitted: '/private/var/folders/st/r_c40wz94cnf4c426r0lvp600000gn/T/pip-uninstall-b9GLPD/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc', '/private/var/folders/st/r_c40wz94cnf4c426r0lvp600000gn/T/pip-uninstall-b9GLPD/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc', "[Errno 1] Operation not permitted: '/private/var/folders/st/r_c40wz94cnf4c426r0lvp600000gn/T/pip-uninstall-b9GLPD/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib', '/private/var/folders/st/r_c40wz94cnf4c426r0lvp600000gn/T/pip-uninstall-b9GLPD/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib', "[Errno 1] Operation not permitted: '/private/var/folders/st/r_c40wz94cnf4c426r0lvp600000gn/T/pip-uninstall-b9GLPD/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib'")]
我是在安装python27对应版本的tensorflow时候遇到报错。
原因是无权限写入,原命令为:
pip2 install tensorflow
解决方法有三种:
1.启动一个虚拟环境来安装
python2 -m venv env
source ./env/bin/activate
python -m pip install tensorflow
2.安装到user文件夹中
python2 -m pip install --user tensorflow
3.安装到系统文件夹中
sudo python2 -m pip install tensorflow