刚准备学习tensorflow,发现昨天刚发布了2.0大版本更新,好开心,然而。
> pip install tensorflow
Successfully installed absl-py-0.7.0 astor-0.7.1 gast-0.2.2 grpcio-1.19.0 h5py-2.9.0 keras-applications-1.0.7 keras-preprocessing-1.0.9 markdown-3.0.1 mock-2.0.0 pbr-5.1.3 protobuf-3.7.0 tensorboard-1.13.1 tensorflow-1.13.1 tensorflow-estimator-1.13.0 termcolor-1.1.0 werkzeug-0.14.1 wheel-0.33.1
安装成功,版本是1.13.1,并不是刚更新的2.0,而且import报错。
import tensorflow as tf
Traceback (most recent call last):
File "C:\Program Files\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Program Files\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Program Files\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "C:\Program Files\Python37\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Program Files\Python37\lib\imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: DLL load failed: 动态链接库(DLL)初始化例程失败。
我的系统是win10-x64,cpu是奔腾E5700
可能是cpu或者操作系统不支持这版tensorflow?
卸载重装,指定版本为2.0.0a0,结果还是一样的错误。
降低版本到python3.6+tensorflow1.10.0,依然报错。
最后尝试使用Anaconda安装。
安装成功,可是安装好的版本是conda自动匹配到的:python-3.6.2+tensorflow-1.2.1。(可能真是cpu或者系统的兼容问题?)
Anaconda官网中下载并安装,执行以下命令即可。
> conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
> conda config --set show_channel_urls yes
> conda create -n tensorflow python=3.7.1
> activate tensorflow
> conda install tensorflow
下次直接 > python 进入时,import依然会报错。所以进入tensorflow需要再次执行命令
> activate tensorflow
> python