安装tensorflow,import报错。

刚准备学习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
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值