ModuleNotFoundError Traceback (most recent call last) in () 11 import numpy as np 12 ---> 13 import tensorflow as tf 14 15
ModuleNotFoundError: No module named 'tensorflow'
ModuleNotFoundError Traceback (most recent call last) in () 11 import numpy as np 12 ---> 13 import tensorflow as tf 14 15
ModuleNotFoundError: No module named 'tensorflow'
I was looking for a similar issue (unable to import tensorflow in jupyter) and found that maybe most answers are outdated because now conda installs tf in its own environment.
The most useful thing I found is:
https://docs.anaconda.com/anaconda/user-guide/tasks/tensorflow/
which explains in very few steps how to install tf or tf-gpu in its own environment.
Then my problem was that the jupyter notebook is in its own base environment, not in the tf-gpu environment. How to work with that from a jupyter notebook based on the base environment?
The solution comes from the very helpful answer from Nihal Sangeeth to this question
https://stackoverflow.com/questions/53004311/how-to-add-conda-environment-to-jupyter-lab
conda activate tf-gpu
(tf-gpu)$ conda install ipykernel
(tf-gpu)$ ipython kernel install --user --name=<any_name_you_like_for_kernel>
(tf-gpu)$ conda deactivate
Close and reopen your jupyter notebook. Then in your jupyter notebook you will find the option, under "kernel" of "change kernel". Change kernel to your newly created kernel and you will be able to import tensorflow as tf and go on from there.
Hope it helps somebody
You can use following commands to import by Anaconda prompt:
conda install tensorflow
it will download all tensorflow environment setup.
then you can check any where:
import tensorflow
This might occur from several issues
pip install --upgrade tensorflow
Are you sure you're in the same conda enviroment which has tensorflow isntalled ?
conda env list
# conda environments: deep-learning /Users/wassimseifeddine/anaconda/anaconda3/envs/deep-learning root /Users/wassimseifeddine/anaconda/anaconda3
try switching between this environments source activate <env-name>
and trying pip freeze
to chech if tensorflow is installed.