安装tensorflow
pip install tensorflow==1.4.0
在安装完tensorflow后执行
>>> import tensorflow as tf时,报错,错误信息
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "E:\anaconda\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
File "E:\anaconda\lib\site-packages\tensorflow\python\__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "E:\anaconda\lib\site-packages\tensorflow\core\framework\graph_pb2.py", line 6, in <mo
dule>
from google.protobuf import descriptor as _descriptor
File "E:\anaconda\lib\site-packages\google\protobuf\descriptor.py", line 47, in <module>
from google.protobuf.pyext import _message
ImportError: DLL load failed: 找不到指定的程序。
解决:
从报错信息看是protobuf的问题,卸载protobuf,安装较低版本的protobuf
pip uninstall protobuf
pip install protobuf==3.3.0
当不知道设备支持哪些版本的protobuf时,运行
pip install protobuf==xxx,会出现提示,提示展示的即包含需要找的版本
Collecting protobuf==xxx
Could not find a version that satisfies the requirement protobuf==xxx (from versions: 2.0.0
b0, 2.0.3, 2.3.0, 2.4.1, 2.5.0, 2.6.0, 2.6.1, 3.0.0a2, 3.0.0a3, 3.0.0b1, 3.0.0b1.post1, 3.0.0
b1.post2, 3.0.0b2, 3.0.0b2.post1, 3.0.0b2.post2, 3.0.0b3, 3.0.0b4, 3.0.0, 3.1.0, 3.1.0.post1,
3.2.0rc1, 3.2.0rc1.post1, 3.2.0rc2, 3.2.0, 3.3.0, 3.4.0, 3.5.0.post1, 3.5.1, 3.5.2, 3.5.2.po
st1, 3.6.0, 3.6.1, 3.7.0rc2, 3.7.0rc3, 3.7.0, 3.7.1, 3.8.0rc1)
No matching distribution found for protobuf==xxx
此时再执行
>>> import tensorflow as tf
>>> tf.__version__
'1.4.0'
安装成功