Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No module named 'tensorflow.python.platform'

I am using python3 and have installed tensorflow-gpu using:

pip3 install tensorflow-gpu==1.13.1

And have checked that it is installed by:

pip3 show tensorflow-gpu
Name: tensorflow-gpu
Version: 1.13.1
Summary: TensorFlow is an open source machine learning framework for 
everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: [email protected]
License: Apache 2.0
Location: /usr/lib64/python3.6/site-packages
Requires: tensorflow-estimator, keras-applications, termcolor, absl-py, six, 
astor, protobuf, wheel, keras-preprocessing, gast, grpcio, numpy, 
tensorboard
Required-by:

but when I do the following it gives me an error:

user:/home/mydirectory # python3
Python 3.6.5 (default, Mar 31 2018, 19:45:04) [GCC] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.6/site-packages/tensorflow/__init__.py", line 24, 
in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: 
disable=unused-import
  File "/usr/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 25, in <module>
    from tensorflow.python.platform import self_check
ModuleNotFoundError: No module named 'tensorflow.python.platform'

I see from the error that its looking for tensorflow in directory

/usr/lib/python3.6/site-packages/tensorflow

But pip indicates that its installed at

/usr/lib64/python3.6/site-packages

How can I fix this issue?

like image 284
Harry Boy Avatar asked Jun 20 '19 15:06

Harry Boy


2 Answers

Please follow below steps..
0) please login with root permission or sudo and write this command in terminal 

1)pip3 install tensorflow-gpu==1.13.1   

2)pip3 --version
  pip 8.1.1 from /usr/lib/python3/dist-packages (python 3.5)   
3)shekh@shekh:~$ python3
  Python 3.5.2 (default, Nov 12 2018, 13:43:14) 
  [GCC 5.4.0 20160609] on linux
  Type "help", "copyright", "credits" or "license" for more information.
  >>>

https://www.tensorflow.org/install/pip

 for reference

tensorflow test run

like image 154
Shekh Firoz Alam Avatar answered Sep 30 '22 17:09

Shekh Firoz Alam


See https://github.com/tensorflow/tensorflow/issues/374

Are you opening the terminal from within the tensorflow directory?

"Actually I had this issue because I was trying to import tensorflow from a python session inside the tensorflow repo folder, going to some other folder and starting python and importing tensorflow worked for me."

like image 27
Sohrab T Avatar answered Sep 30 '22 17:09

Sohrab T