Win10安装TensorFlow
2020-02-10 本文已影响0人
Sam_L
打开Anaconda Prompt
1、输入:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
这两行代码用来改成连接清华镜像的
我这个
.condar文件
没有这2行,如果找不到这个文件就等安装完后再找
C:\Users\Administrator.condarc文件:
删除两行代码:
ssl_verify: true
-defaults
2、输入:
conda create -n tensorflow python=3.6
提示输入y
<界面提示activate tensorflow>
3、我们要安装的是CPU版本,那么在命令下紧接着输入:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow
安装过程可能会提示:pip的版本需更新,安装提示输入指令即可。
在我安装的过程中出现了错误
Cannot uninstall wrapt

解决方案:
pip install wrapt --ignore-installed
重新执行安装,安装成功!
4、测试:
(1)输入
activate TensorFlow
(2)输入:python
进入python后依次输入:
import tensorflow as tf
报错:显示no module named ‘tensorflow’

解决:
- 查看:在tensorflow环境下运行
conda list
发现没有tensorflow numpy等包。

- 在tensorflow环境下执行:
conda install tensorflow
提示输入y
- 再次查看:
conda list
- 然后在TensorFlow环境下输入
python
,重新进行测试
import tensorflow as tf
print(tf.__version__)

完成喽!
你还可以使用spyder(如果提示使用不了,降低Spyder版本,我原来是4.0.1,后改成3.3.6)
1)选择tensorflow应用
2)选择spyder--》Launch

import tensorflow as tf
hello = tf.constant("Hello TensorFlow")
sess = tf.Session()
print(sess.run(hello))

参考:
https://blog.csdn.net/weixin_41923658/article/details/96127770
https://blog.csdn.net/qq_40132185/article/details/89025784