Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix 'ModuleNotFoundError: No module named 'tensorflow._api' in TensorFlow Keras API with Python 3.6.5

~\AppData\Roaming\Python\Python36\site-packages\tensorflow\__init__.py in <module>()
     37   print('tf.estimator package not installed.')
     38 
---> 39 from tensorflow._api.v1 import app
     40 from tensorflow._api.v1 import bitwise
     41 from tensorflow._api.v1 import compat

ModuleNotFoundError: No module named 'tensorflow._api'

This is the error I keep receiving every time I try to run my code.

I have tried reinstalling tensorflow from https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.12.0-cp36-cp36m-win_amd64.whl but every time I get the above error.

these are the libraries I am importing.

import tensorflow as tf
from tensorflow.keras.callbacks import TensorBoard
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Dropout, Activation, Flatten
from tensorflow.keras.layers import Conv2D, MaxPooling2D
import pickle

I am running Windows 10(64-bit)

like image 759
Neetu Vikram Avatar asked May 21 '26 20:05

Neetu Vikram


1 Answers

This error may be because Tensorflow might not have been installed properly in your PC.

There might be multiple reasons for that. So, there can be multiple solutions, as mentioned below.

Please let me know if your issue still persists after trying the below instructions. Thanks.

You can try

pip uninstall tensorflow
pip uninstall tensorflow_estimator
pip install tensorflow tensorflow_estimator

Just to make sure. If the tensorflow_estimator uninstall fails (with not found) just ignore that error.

Or, you can try installing Tensorflow in python3 prompt.

Or, In your pip install command, could you try adding the --ignore_installed flag

Or the error may be from the multiple Python distributions in your PC. Can you try removing all the other ones from your PATH file, and check if the issue is resolved.

For more information, please refer the below links.

https://github.com/tensorflow/tensorflow/issues/29750

https://github.com/tensorflow/tensorflow/issues/6548


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!