ubuntu 14.04 用pip3(python3)安装TensorFlow成功,但是import 显示 No module named 'tensorflow'

如题

sudo -H pip3 install tensorflow 

安装成功,不成功可能是各种依赖库没有装或者版本没对上。

执行python3命令

~$ python3
Python 3.7.0 (default, Jun 28 2018, 13:15:42) 
[GCC 7.2.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tensorflow'
>>> quit()

结果一看,这里面python3的版本和TensorFlow 安装时打印信息显示的版本(python3.4)不一致,好吧,应该是装在python3.4上的。这里估计是anaconda 安装后,搞混了。

直接在命令行输入:

~$ python3.4
Python 3.4.3 (default, Nov 12 2018, 22:25:49) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
>>> import tensorflow as tf
>>> hello = tf.constant('Hello,world!')
>>> sess = tf.Session()
2019-01-12 04:18:42.349465: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
>>> result = sess.run(hello)
>>> sess.close()
>>> print(result)
b'Hello,world!'
>>> quit()

这样就可以了,注意版本问题。

 

其他问题可以看看:

ubuntu 下安装完tensorflow 后 import 提示 no module named tensorflow

 

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值