在Windows上升级tensorflow

时间:2017-10-19 23:55:51

标签: python tensorflow anaconda

如何升级Windows机器上的tensoflow库? Tensorflow目前已安装并运行正常。我正在使用anaconda发行版。

import tensorflow as tf

tf.VERSION
Out[37]: '1.2.1'

我的python版本在

之下
>python -V
Python 3.5.3 :: Anaconda custom (64-bit)

--------------- update 1 ------------------------------ ------------

尝试了第一个回答并得到以下信息

>pip install tensorflow --upgrade
Collecting tensorflow
  Downloading tensorflow-1.3.0-cp35-cp35m-win_amd64.whl (25.5MB)
    100% |################################| 25.5MB 47kB/s
Collecting protobuf>=3.3.0 (from tensorflow)
  Downloading protobuf-3.4.0-py2.py3-none-any.whl (375kB)
    100% |################################| 378kB 1.4MB/s
Requirement already up-to-date: numpy>=1.11.0 in c:\users\johndoe\appdata\local\conda\conda\envs\tensorflowspyder\lib\site-packages (from tensorflow)
Collecting tensorflow-tensorboard<0.2.0,>=0.1.0 (from tensorflow)
  Downloading tensorflow_tensorboard-0.1.8-py3-none-any.whl (1.6MB)
    100% |################################| 1.6MB 591kB/s
Requirement already up-to-date: six>=1.10.0 in c:\users\johndoe\appdata\local\conda\conda\envs\tensorflowspyder\lib\site-packages (from tensorflow)
Collecting wheel>=0.26 (from tensorflow)
  Downloading wheel-0.30.0-py2.py3-none-any.whl (49kB)
    100% |################################| 51kB 1.2MB/s
Collecting setuptools (from protobuf>=3.3.0->tensorflow)
  Downloading setuptools-36.6.0-py2.py3-none-any.whl (481kB)
    100% |################################| 481kB 1.1MB/s
Requirement already up-to-date: werkzeug>=0.11.10 in c:\users\johndoe\appdata\local\conda\conda\envs\tensorflowspyder\lib\site-packages (from tensorflow-tensorboard<0.2.0,>=0.1.0->tensorflow)
Requirement already up-to-date: bleach==1.5.0 in c:\users\johndoe\appdata\local\conda\conda\envs\tensorflowspyder\lib\site-packages (from tensorflow-tensorboard<0.2.0,>=0.1.0->tensorflow)
Collecting markdown>=2.6.8 (from tensorflow-tensorboard<0.2.0,>=0.1.0->tensorflow)
  Downloading Markdown-2.6.9.tar.gz (271kB)
    100% |################################| 276kB 1.5MB/s
Requirement already up-to-date: html5lib==0.9999999 in c:\users\johndoe\appdata\local\conda\conda\envs\tensorflowspyder\lib\site-packages (from tensorflow-tensorboard<0.2.0,>=0.1.0->tensorflow)
Building wheels for collected packages: markdown
  Running setup.py bdist_wheel for markdown ... done
  Stored in directory: C:\Users\johndoe\AppData\Local\pip\Cache\wheels\bf\46\10\c93e17ae86ae3b3a919c7b39dad3b5ccf09aeb066419e5c1e5
Successfully built markdown
Installing collected packages: setuptools, protobuf, markdown, wheel, tensorflow-tensorboard, tensorflow
  Found existing installation: setuptools 36.2.0
    Uninstalling setuptools-36.2.0:
      Successfully uninstalled setuptools-36.2.0
  Rolling back uninstall of setuptools
Exception:
Traceback (most recent call last):
  File "C:\Users\johndoe\AppData\Local\conda\conda\envs\tensorflowspyder\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "C:\Users\johndoe\AppData\Local\conda\conda\envs\tensorflowspyder\lib\site-packages\pip\commands\install.py", line 342, in run
    prefix=options.prefix_path,
  File "C:\Users\johndoe\AppData\Local\conda\conda\envs\tensorflowspyder\lib\site-packages\pip\req\req_set.py", line 784, in install
    **kwargs
  File "C:\Users\johndoe\AppData\Local\conda\conda\envs\tensorflowspyder\lib\site-packages\pip\req\req_install.py", line 851, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "C:\Users\johndoe\AppData\Local\conda\conda\envs\tensorflowspyder\lib\site-packages\pip\req\req_install.py", line 1064, in move_wheel_files
    isolated=self.isolated,
  File "C:\Users\johndoe\AppData\Local\conda\conda\envs\tensorflowspyder\lib\site-packages\pip\wheel.py", line 247, in move_wheel_files
    prefix=prefix,
  File "C:\Users\johndoe\AppData\Local\conda\conda\envs\tensorflowspyder\lib\site-packages\pip\locations.py", line 140, in distutils_scheme
    d = Distribution(dist_args)
  File "C:\Users\johndoe\AppData\Local\conda\conda\envs\tensorflowspyder\lib\site-packages\setuptools\dist.py", line 365, in __init__
    self._finalize_requires()
  File "C:\Users\johndoe\AppData\Local\conda\conda\envs\tensorflowspyder\lib\site-packages\setuptools\dist.py", line 372, in _finalize_requires
    if not self.install_requires:
AttributeError: 'Distribution' object has no attribute 'install_requires'

我的版本仍然相同

---------------- UPDATE2 ------------------------------ ----  我再次运行相同的命令并得到以下消息

>pip install tensorflow --upgrade
Collecting tensorflow
  Using cached tensorflow-1.3.0-cp35-cp35m-win_amd64.whl
Collecting tensorflow-tensorboard<0.2.0,>=0.1.0 (from tensorflow)
  Using cached tensorflow_tensorboard-0.1.8-py3-none-any.whl
Requirement already up-to-date: numpy>=1.11.0 in c:\users\johndoe\appdata\local\conda\conda\envs\tensorflowspyder\lib\site-packages (from tensorflow)
Collecting protobuf>=3.3.0 (from tensorflow)
  Using cached protobuf-3.4.0-py2.py3-none-any.whl
Requirement already up-to-date: six>=1.10.0 in c:\users\johndoe\appdata\local\conda\conda\envs\tensorflowspyder\lib\site-packages (from tensorflow)
Collecting wheel>=0.26 (from tensorflow)
  Using cached wheel-0.30.0-py2.py3-none-any.whl
Requirement already up-to-date: html5lib==0.9999999 in c:\users\johndoe\appdata\local\conda\conda\envs\tensorflowspyder\lib\site-packages (from tensorflow-tensorboard<0.2.0,>=0.1.0->tensorflow)
Collecting markdown>=2.6.8 (from tensorflow-tensorboard<0.2.0,>=0.1.0->tensorflow)
Requirement already up-to-date: bleach==1.5.0 in c:\users\johndoe\appdata\local\conda\conda\envs\tensorflowspyder\lib\site-packages (from tensorflow-tensorboard<0.2.0,>=0.1.0->tensorflow)
Requirement already up-to-date: werkzeug>=0.11.10 in c:\users\johndoe\appdata\local\conda\conda\envs\tensorflowspyder\lib\site-packages (from tensorflow-tensorboard<0.2.0,>=0.1.0->tensorflow)
Collecting setuptools (from protobuf>=3.3.0->tensorflow)
  Using cached setuptools-36.6.0-py2.py3-none-any.whl
Installing collected packages: setuptools, protobuf, markdown, wheel, tensorflow-tensorboard, tensorflow
  Found existing installation: setuptools 36.2.0
    Uninstalling setuptools-36.2.0:
      Successfully uninstalled setuptools-36.2.0
  Found existing installation: protobuf 3.3.0
    Uninstalling protobuf-3.3.0:
      Successfully uninstalled protobuf-3.3.0
  Found existing installation: Markdown 2.6.8
    Uninstalling Markdown-2.6.8:
      Successfully uninstalled Markdown-2.6.8
  Found existing installation: wheel 0.29.0
    Uninstalling wheel-0.29.0:
      Successfully uninstalled wheel-0.29.0
  Found existing installation: tensorflow 1.2.1
    Uninstalling tensorflow-1.2.1:
      Successfully uninstalled tensorflow-1.2.1
Successfully installed markdown-2.6.9 protobuf-3.4.0 setuptools-36.6.0 tensorflow-1.3.0 tensorflow-tensorboard-0.1.8 wheel-0.30.0

我检查过,似乎tensorflow版本已升级

tf.VERSION
Out[2]: '1.3.0'

2 个答案:

答案 0 :(得分:11)

像普通包装一样升级它:

如果在conda环境中安装了tensorflow

activate your-conda-environment

然后:

pip install pip --upgrade
pip install tensorflow --upgrade

这对我有用。

答案 1 :(得分:1)

我不允许发表评论,因此我将其写为答案。 以下对我有用:

pip install --user tensorflow --upgrade

没有“用户”,即使以管理员身份运行提示符,我也收到以下错误:

ERROR: Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 
Consider using the `--user` option or check the permissions.