Problem: Jupyter says "Module not found" when I try to import Tensorflow on Mac.
Background:
Virtualenv 16.7.9 installed & activated (venv)
Python 3.7.6 installed
PIP 19.3.1 installed
Tensorflow 2.1.0 installed using PIP as per official install instructions
At the command line, I can activate venv, start python3 then import tensorflow and display the tensorflow version correctly. But Tensorflow won't import from within Jupiter. And if I try to change the kernel within a Jupyter notebook, only Python3 is listed.
On other threads, people recommend using anaconda, but I've used PIP to install Tensorflow as recommended in the above link.
Any ideas?
Install a Jupyter Kernel
You need to install a kernel inside the env and then use Jupyter.
ipython kernel install --user --name=.venv
Then restart jupyter, click new, you should see .venv in your kernel list.
Related
I recently installed an upgraded version of TensorFlow through the terminal by executing the command: "pip install --upgrade tensorFlow --user".
However, I see in my terminal: "Requirement already satisfied: tensorflow in c:\users\appdata\local\programs\python\python38\lib\site-packages (2.9.1)" , but when I check the version of tensorflow in my Jupyter, I get that the tensorflow version 2.4.0.
Any suggestions on how to get the updated version of Tensorflow in Jupyter?
Edit: I also have Python 3.8.7
Jupyter Image
Terminal image
You might see the different versions in both interfaces because TensorFlow is getting installed at a different place.
If you want to install an upgraded TensorFlow version on your current working jupyter notebook, then:
You may need to open the anaconda command prompt in the same environment where you are using jupyter notebook and install the tensorflow using same code and check the TensorFlow version.
OR
You can also install it by running the same code in the same jupyter notebook cell.
!pip install --upgrade
tensorFlow --user
I have installed tensorflow in a virtual environment and can import Tensorflow in jupyter notebook or terminal. I am now learning to use VScode, so I try to launch it in the jupyter notebook within the VScode, but Tensorflow cannot be imported.
It shows ModuleNotFoundError: No module named 'tensorflow', but I have installed it and it can be used in the terminal or jupyternotebook.
I also tried to define the path of the python interpreter, but it did not work. Could someone help me out? Tons of thanks.
Try:
This works for me.
pip --version
python -m pip install --upgrade pip
pip3 install tensorflow==2.0.0
pip --version
python -m pip install --upgrade pip
pip3 install tensorflow==2.8.0
Worked for me.
I followed instructions given in the TensorFlow website to install tensorflow_hub and installed it within a conda environment.
$ pip install "tensorflow>=2.0.0"
$ pip install --upgrade tensorflow-hub
I ran the above in anaconda prompt
But I'm still getting ModuleNotFoundError for 'tensorflow_hub'.
Any help here is appreciated. Thanks in advance
First thing
Check whether you have installed tensorflow_hub within that environment
conda list
If you can not find it there, maybe you have been installing it to another environment which does not matter, just install it again here.
pip install tensorflow_hub
You have probably done that so most likely you are using another kernel within your jupyter notebook, so either go to the environment of that kernel and install your package there. Or the preferred way, install your current environment yourenvironment as a new kernel and use that one in your jupyter notebook
python -m ipykernel install --user --name=yourenvironment
Now start your jupyter notebook and enjoy your package
I am using python notebooks using Anaconda for datascience and I'm trying to install tensor flow.
I have followed this tutorial:
https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/install.html
and everything is fine. I can type import tensorflow as tf as written and I haven't errors. But when I return to python notebooks and I write import tensorflow as tf i continue to have this error:
No module named 'tensorflow'
How can I fix it?
You should have installed Jupiter notebook within your Conda environment.
conda activate <your-environment-name>
conda install -c anaconda jupyter
This solved the same problem for me.
Please follow the below steps to easily use your anaconda environment from jupyter notebook.
conda create -n myenv
source activate myenv
python -m ipykernel install --user --name myenv --display-name "Python(myenv)"
You can now switch the kernel in jupyter notebook and import all the packages that you have installed in your conda environment.
I am using an Ubuntu docker image. I've installed Anaconda on it with no issues. I'm not trying to install tensorflow, using the directions on the tensorflow website:
conda create --name tensorflow python=3.5
source activate tensorflow
<tensorflow> conda install -c conda-forge tensorflow
It installs with no errors. However, when I import in iPython, it tells me there is no module tensorflow. But if I import when in Python, it works fine.
What's going on and how do I fix it?
You have to install IPython in the conda environment
source activate tensorflow
conda install ipython
I went through the same thing. We are installing tensorflow in different conda environment. So It may not consist of all the packages. I needed to install jupyter notebook separately in order to work.