[Solved] No module named ‘tensorflow.python.tools’; ‘tensorflow.python’ is not a package

Everything was working smoothly until I started getting the following error:

Traceback (most recent call last):
File “”, line 1, in
File “/home/user/Workspace/Practices/Tensorflow/tensorflow2/venv/lib/python3.7/site-packages/tensorflow/init.py”, line 98, in
from tensorflow_core import *
File “/home/user/Workspace/Practices/Tensorflow/tensorflow2/venv/lib/python3.7/site-packages/tensorflow_core/init.py”, line 40, in
from tensorflow.python.tools import module_util as _modle_util
ModuleNotFoundError: No module named ‘tensorflow.python.tools’; ‘tensorflow.python’ is not a package

My environment setup:

  • python-3.7
  • Using venv module to create virtual environment
    tensorflow 2.0.0
  • pip 19.0.3
  • Manjaro Linux

Now, I even can’t import tensorflow module as well. It gives same above error. Tried reinstalling with cache and without cache as well, but no luck. Recreated virtual environment as well, no luck. This is really weird and have no clue where to start troubleshooting as well. Looking at virtual environment site packages, everything seems fine.

Solution #1:

I just faced this problem right now. I ran the source code on another computer and it showed the same error. I went ahead and compared the version of TensorFlow and turns out that the other computer was running tensorflow==2.1.0 and mine was running tensorflow==1.14.0.

In short, downgrade your tensorflow installation (pip install tensorflow==1.
14.0)

Respondent: Mujeeb Ishaque
Solution #2:

Found a noob problem. I was using my file name as csv.py which already exist in python library, which I think was messing up the paths. But don’t know how yet.

Respondent: Mani Rai
Solution #3:

Try uninstalling and reinstalling. First run:

pip uninstall tensorflow

then reinstall:

pip install tensorflow==2.0

After you uninstall, in the python shell, run:

help('modules')

TensorFlow should not be there in that list. Only then proceed to install it.

Respondent: Sushanth
Solution #4:

Try downgrading to Tensorflow 1.15

Respondent: ARH
The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published.