ImportError: No module named tensorflow
Solution 1
Try installing tensorflow again with the whatever version you want and with option --ignore-installed like:
pip install tensorflow==1.2.0 --ignore-installed
I solved same issue using this command.
Solution 2
I had a more basic problem when I received this error.
The "Validate your installation" instructions say to type: python
However, I have both 2.7 and 3.6 installed. Because I used pip3 to install tensorflow, I needed to type: python3
Using the correct version, I could import the "tensorflow" module.
Solution 3
Check if Tensorflow was installed successfully using:
pip3 show tensorflow
If you get something like
Name: tensorflow
Version: 1.2.1
Summary: TensorFlow helps the tensors flow
Home-page: http://tensorflow.org/
Author: Google Inc.
Author-email: [email protected]
License: Apache 2.0
Location: /usr/local/lib/python3.5/dist-packages
Requires: bleach, markdown, html5lib, backports.weakref, werkzeug, numpy, protobuf, wheel, six
You may try adding the path of your tensorflow location by:
export PYTHONPATH=/your/tensorflow/path:$PYTHONPATH.
Solution 4
For Anaconda3, simply install in Anaconda Navigator:
Solution 5
Try installing tensorflow in the user site - This installation only works for you.
pip install tensorflow --user
Abhishek Gangwar
Updated on September 07, 2021Comments
-
Abhishek Gangwar over 2 years
Please help me with this error
I have installed the tensorflow module on my server and below is it's information
15IT60R19@cpusrv-gpu-109:~$ pip show tensorflow Name: tensorflow Version: 1.0.0 Summary: TensorFlow helps the tensors flow Home-page: http://tensorflow.org/ Author: Google Inc. Author-email: [email protected] License: Apache 2.0 Location: /home/other/15IT60R19/anaconda2/lib/python2.7/site-packages Requires: mock, numpy, protobuf, wheel, six
But when I try to import tensorflow I get following error
>>> import tensorflow as tf Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named tensorflow
My python version is as following
Python 2.7.12 |Anaconda 2.5.0 (64-bit)| (default, Jul 2 2016, 17:42:40) [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2 Type "help", "copyright", "credits" or "license" for more information. Anaconda is brought to you by Continuum Analytics. Please check out: http://continuum.io/thanks and https://anaconda.org
I have tried the solutions given in sol1
I do not have sudo access to the server I can only use pip to install any module
-
Tamas Ionut over 6 yearsInstallation of tensorflow works perfectly with Anaconda Navigator.
-
Schütze about 6 yearsIt still says
ImportError: No module named tensorflow
-
zhangjiangtao about 6 yearsAdding the path can be help for me.
-
Arthur Attout over 5 yearsI tried it and it yielded
Could not find a version that satisfies the requirement tensorflow (from versions: ) No matching distribution found for tensorflow
-
Dharma about 5 yearsI think you can try newer versions then. You can uninstall the previous one and do fresh install instead.
-
Ajp over 4 yearsThis did it for me on Python 3.6
-
Adrien Pavao about 4 yearsJust use
pip3 install
instead ofpip install
. -
Amogh Mishra about 4 yearsI had the same issue and it got resolved with this
pip install tensorflow --ignore-installed --user
-
Woden over 3 yearsI use @AmoghMishra's method and add the path in the environmental variables and it works!