I have installed Keras and tensorflow using pip in Anaconda environment, but when I run Keras program in tensorflow background it gives error No module named tensorflow
. Can you please help?
The Python "ModuleNotFoundError: No module named 'tensorflow'" occurs when we forget to install the tensorflow module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install tensorflow command.
We can fix no module named Keras using installing and reinstalling keras. We can install the Keras module using pip, conda, source code, etc.
Check your python version and installation command. ($ conda create -n tensorflow python=<version>
)
If you install tensorflow via conda-forge use:
# Linux/Mac OS X, Python 2.7/3.4/3.5, CPU only:
(tensorflow)$ conda install -c conda-forge tensorflow
Otherwise, switch the pip command according to the python version like:
# Python 2
(tensorflow)$ pip install --ignore-installed --upgrade $TF_BINARY_URL
# Python 3
(tensorflow)$ pip3 install --ignore-installed --upgrade $TF_BINARY_URL
If this doesn't solve your problem, please provide more detailed command lines to reproduce the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With