简体   繁体   中英

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.

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)

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.

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.

You don't need to uninstall tensorflow what version you have because it will take time to reinstall. You can fix this issue just by installing tensorflow==2.0.

pip install tensorflow==2.0

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.

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