Tensorflow 安装问题解决

最近在弄机器学习,需要安装tensorflow这个库,于是按照tensorflow中文教程安装,结果很不顺利。接下来就把遇到的问题给大家说一下,并说明解决方案。


1、安装官网安装方法,我在mac环境下安装总会抱这个错,

Traceback (most recent call last):

  File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 215, in main

    status = self.run(options, args)

  File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 324, in run

    requirement_set.prepare_files(finder)

  File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 380, in prepare_files

    ignore_dependencies=self.ignore_dependencies))

  File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 620, in _prepare_file

    session=self.session, hashes=hashes)

  File "/Library/Python/2.7/site-packages/pip/download.py", line 821, in unpack_url

    hashes=hashes

  File "/Library/Python/2.7/site-packages/pip/download.py", line 659, in unpack_http_url

    hashes)

  File "/Library/Python/2.7/site-packages/pip/download.py", line 882, in _download_http_url

    _download_url(resp, link, content_file, hashes)

  File "/Library/Python/2.7/site-packages/pip/download.py", line 605, in _download_url

    consume(downloaded_chunks)

  File "/Library/Python/2.7/site-packages/pip/utils/__init__.py", line 852, in consume

    deque(iterator, maxlen=0)

  File "/Library/Python/2.7/site-packages/pip/download.py", line 571, in written_chunks

    for chunk in chunks:

  File "/Library/Python/2.7/site-packages/pip/utils/ui.py", line 139, in iter

    for x in it:

  File "/Library/Python/2.7/site-packages/pip/download.py", line 560, in resp_read

    decode_content=False):

  File "/Library/Python/2.7/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 357, in stream

    data = self.read(amt=amt, decode_content=decode_content)

  File "/Library/Python/2.7/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 324, in read

    flush_decoder = True

  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py", line 35, in __exit__

    self.gen.throw(type, value, traceback)

  File "/Library/Python/2.7/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 246, in _error_catcher

    raise ReadTimeoutError(self._pool, None, 'Read timed out.')

ReadTimeoutError: HTTPSConnectionPool(host='storage.googleapis.com', port=443): Read timed out.

我以为是网络问题,结果经过各方考证,不是这个原因。由于国内镜像原因,在加上天朝,这个你懂的。我就不说明了。

在机器学习群请教大佬后,放弃线上安装方法,通过Python官网库的安装方法。将安装包下载下来进行安装。

sudo pip install tensorflow路径 (sudo pip install /xxx/xxx/xxx/tensorflow-1.4.1-cp27-cp27m-macosx_10_11_x86_64.whl)

一路很顺畅,正在高兴的时候,突然又显红了。

报错如下

 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/basecommand.py", line 215, in main

    status = self.run(options, args)

  File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 342, in run

    prefix=options.prefix_path,

  File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 778, in install

    requirement.uninstall(auto_confirm=True)

  File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 754, in uninstall

    paths_to_remove.remove(auto_confirm)

  File "/Library/Python/2.7/site-packages/pip/req/req_uninstall.py", line 115, in remove

    renames(path, new_path)

  File "/Library/Python/2.7/site-packages/pip/utils/__init__.py", line 267, 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: '/tmp/pip-1lcfuc-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info'

该提示告诉我们numpy版本问题,告诉我先删除现有版本,再安装支持tensorflow的版本,按照指示,sudo pip uninstall  numpy  结果提示我权限不够。

The directory '/Users/bene/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

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:

  /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info

Proceed (y/n)? y

Exception:

Traceback (most recent call last):

  File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 215, in main

    status = self.run(options, args)

  File "/Library/Python/2.7/site-packages/pip/commands/uninstall.py", line 76, in run

    requirement_set.uninstall(auto_confirm=options.yes)

  File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 346, in uninstall

    req.uninstall(auto_confirm=auto_confirm)

  File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 754, in uninstall

    paths_to_remove.remove(auto_confirm)

  File "/Library/Python/2.7/site-packages/pip/req/req_uninstall.py", line 115, in remove

    renames(path, new_path)

  File "/Library/Python/2.7/site-packages/pip/utils/__init__.py", line 267, 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: '/tmp/pip-R_dkKX-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info'

无解。

只有另寻出路。

从新单独更新numpy库,不理会现有的版本 :sudo pip install numpy --upgrade --ignore-installed

成功!!!!

再重新安装一下:

....

....

....

Successfully installed backports.weakref-1.0.post1 funcsigs-1.0.2 futures-3.2.0 html5lib-0.9999999 markdown-2.6.10 mock-2.0.0 pbr-3.1.1 tensorflow-1.4.1 tensorflow-tensorboard-0.4.0rc3

搞定!!!

你可能感兴趣的:(Tensorflow 安装问题解决)