发布日期:2019-11-30 14:39:37

安装tensorflow时遇到的问题即解决方法。

安装tensoflow前的准备

(通过pip安装,如果还没有安装pip的话,可以通过下面的命令安装pip)

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo python get-pip.py

 

安装命令

pip install tensorflow 

ERROR: matplotlib 1.3.1 requires nose, which is not installed.
ERROR: matplotlib 1.3.1 requires tornado, which is not installed.
ERROR: markdown 3.1.1 has requirement setuptools>=36, but you'll have setuptools 18.5 which is incompatible.
ERROR: tensorboard 2.0.2 has requirement setuptools>=41.0.0, but you'll have setuptools 18.5 which is incompatible.
ERROR: google-auth 1.7.1 has requirement setuptools>=40.3.0, but you'll have setuptools 18.5 which is incompatible.
Installing collected packages: wrapt, numpy, six, keras-preprocessing, enum34, absl-py, astor, gast, backports.weakref, tensorflow-estimator, opt-einsum, termcolor, protobuf, google-pasta, oauthlib, urllib3, certifi, chardet, idna, requests, requests-oauthlib, pyasn1, pyasn1-modules, cachetools, rsa, google-auth, google-auth-oauthlib, futures, grpcio, werkzeug, markdown, tensorboard, functools32, funcsigs, mock, h5py, keras-applications, tensorflow
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/wrapt'
Consider using the `--user` option or check the permissions.

解决方法

 通过easy_install安装nose和tornado

sudo easy_install nose
sudo easy_install tornado

升级setuptools到最近的版本

pip install --upgrade setuptools --user

这里使用了--user. 曾经尝试使用sudo pip install --upgrade setuptools, 但是失败。告知no permission.

sudo -H pip install --upgrade setuptools
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting setuptools
  Using cached https://files.pythonhosted.org/packages/9e/d5/444a443d890f09fc1ca1a2c3c9fc7e84cb148177b05ac94fe5084e3d9abb/setuptools-42.0.1-py2.py3-none-any.whl
Installing collected packages: setuptools
  Found existing installation: setuptools 18.5
    Uninstalling setuptools-18.5:
ERROR: Could not install packages due to an EnvironmentError: [('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc', '/private/tmp/pip-uninstall-ZGaszw/markers.pyc', "[Errno 1] Operation not permitted: '/private/tmp/pip-uninstall-ZGaszw/markers.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.py', '/private/tmp/pip-uninstall-ZGaszw/__init__.py', "[Errno 1] Operation not permitted: '/private/tmp/pip-uninstall-ZGaszw/__init__.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py', '/private/tmp/pip-uninstall-ZGaszw/markers.py', "[Errno 1] Operation not permitted: '/private/tmp/pip-uninstall-ZGaszw/markers.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc', '/private/tmp/pip-uninstall-ZGaszw/__init__.pyc', "[Errno 1] Operation not permitted: '/private/tmp/pip-uninstall-ZGaszw/__init__.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib', '/private/tmp/pip-uninstall-ZGaszw', "[Errno 1] Operation not permitted: '/private/tmp/pip-uninstall-ZGaszw'")]

 

发表评论