踩了一圈坑,最后总算安装成功了。
官方的参考文档在这里:https://www.tensorflow.org/install/install_windows
我选择的Installing with native pip
1、安装python
注意,这里要安装64位的python3.5.2版本。下载地址:https://www.python.org/ftp/python/3.5.2/python-3.5.2-amd64.exe。python2.7,python3.6,32位的python3.5.2都不 行。(这真是个大坑)
2、安装VC2015版本
下载地址:https://download.microsoft.com/download/6/D/F/6DF3FF94-F7F9-4F0B-838C-A328D1A7D0EE/vc_redist.x64.exe。这个工具的作用应该是加载dll,如果不装的话。运行代码时会报错:ImportError: DLL load failed: 找不到指定的模块。
3、安装tensorflow
pip install --upgrade tensorflow
安装完成之后,执行以下代码查看效果:
import tensorflow as tf
import os
# disable "The TensorFlow library wasn't compiled to use ... instructions" warning
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))