简体   繁体   中英

ModuleNotFoundError: No module named ‘tensorflow’ in anaconda python 3.6.3

i use Python 3.6.3 |Anaconda custom (64-bit) ubuntu 16.04 64 bits. I installed tensorflow. I did the following steps:

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

I have an import error of tensorflow:

ModuleNotFoundError Traceback (most recent call last)

in () —-> 1 import tensorflow as tf

ModuleNotFoundError: No module named 'tensorflow'

How to solve it? Thanks

When you use anaconda, it's usually better to use the conda installer if possible.

source activate tensorflow
conda install tensorflow

it will display something like:

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      ]

then, you should be able to successfully import 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
>>>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM