python - 模块未找到错误 : No module named ‘tensorflow’ in anaconda python 3. 6.3

标签 python tensorflow machine-learning anaconda

我使用 Python 3.6.3 |Anaconda 自定义(64 位)ubuntu 16.04 64 位。 我安装了 tensorflow 。我执行了以下步骤:

  1. conda create -n tensorflow pip python=3.6
  2. 源激活 tensorflow
  3. pip install –ignore-installed –upgrade\https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.5.0-cp36-cp36m-linux_x86_64.whl

我有一个tensorflow导入错误:

ModuleNotFoundError Traceback(最近一次调用最后)

在()中 —->1 导入tensorflow为tf

ModuleNotFoundError:没有名为“tensorflow”的模块

如何解决?谢谢

最佳答案

当您使用 anaconda 时,如果可能的话,通常最好使用 conda 安装程序。

source activate tensorflow
conda install tensorflow

它将显示如下内容:

Fetching package metadata .......
Solving package specifications: ..........

Package plan for installation in environment 
/usr/local/anaconda3/envs/tensorflow:

The following NEW packages will be INSTALLED:

backports:              1.0-py36_0          
backports.weakref:      1.0rc1-py36_0       
bleach:                 1.5.0-py36_0        
html5lib:               0.9999999-py36_0    
libprotobuf:            3.4.0-0             
markdown:               2.6.9-py36_0        
mkl:                    2017.0.3-0          
numpy:                  1.13.1-py36_0       
protobuf:               3.4.0-py36_0        
six:                    1.10.0-py36_0       
tensorflow:             1.3.0-0             
tensorflow-base:        1.3.0-py36h5293eaa_1
tensorflow-tensorboard: 0.1.5-py36_0        
werkzeug:               0.12.2-py36_0       

 Proceed ([y]/n)? y

Linking packages ...
[      COMPLETE      ]

然后,您应该能够成功导入tensorflow

(tensorflow) user@ubuntu: $ python

Python 3.6.2 |Continuum Analytics, Inc.| (default, Jul 20 2017, 13:51:32) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>>

关于python - 模块未找到错误 : No module named ‘tensorflow’ in anaconda python 3. 6.3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48585469/

相关文章:

python - Scrapy:如何禁用或更改日志?

tensorflow - 获取 Tensorflow Serving 中暴露模型的信息

tensorflow - 如何想象在具有 3 个颜色 channel 的图像上进行卷积/池化

python - 如何为机器学习方法编码我的数据?

amazon-web-services - 我正在尝试创建 AWS Sagemaker Pipeline。客户端错误: An error occurred (ValidationException) when calling the CreatePipeline operation:

algorithm - 随机梯度下降收敛太平滑

python - 筛选 Excel 表格

python - Django 中的资源 View

python - 高效有效的返回包含图片的mongodb结果

variables - 将参数从训练转移到推理图