为了防止意外,首先在conda创建一个新环境并激活:
conda create -n tf2 python=3.5
conda install -n tf2 anaconda
activate tf2
根据TensorFlow 2.0 Beta,用pip安装tf2.0:
pip install tensorflow==2.0.0-beta1
遇到报错,
ERROR: tb-nightly 1.14.0a20190603 has requirement setuptools>=41.0.0, but you'll have setuptools 39.1.0 which is incompatible.
根据在Windows平台下载及安装 TensorFlow,需要更新setuptools
pip install --upgrade setuptools
pip install tensorflow==2.0.0-beta1
再次遇到报错
ERROR: Cannot uninstall 'wrapt'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
用Cannot uninstall 'html5lib'. It is a distutils installed project and thus we cannot accurately的方法解决了,记住这里删除的路径不是anaconda3,而是C:\Users\Lenovo\.conda\envs\tf2.0\Lib\site-packages,删掉了egg-info之后再安装,成功。
测试是否安装成功:
>>>import tensorflow as tf
>>>from tensorflow.keras import layers
>>>print(tf.__version__)
2.0.0-beta1
>>>print(tf.keras.__version__)
2.2.4-tf
启动jupyter notebook后也成功得到一样结果:

在surface上安装tf2.0
在surface上安装的时候遇到一直下载不下来的情况,于是直接下载whl:tensorflow-2.0.0b1-cp35-cp35m-win_amd64.whl
然后用pip安装
pip install tensorflow-2.0.0b1-cp35-cp35m-win_amd64.whl
也遇到了一样的报错,这边egg-info的路径是C:\Users\konat\Anaconda3\envs\tf2\Lib\site-packages,不知道为什么和电脑上不一样。
网友评论