On my jupyter notebook when I run:
!pip3 install tensorflow
I get:
Requirement already satisfied: tensorflow in /home/bluegoblin/.virtualenvs/tf2Env/lib/python3.8/site-packages (2.3.1)
So, this means I do have tensorflow installed on my virtual environment.
But then when I try to import it using import tensorflow as tf
on the same notebook, I get:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-5-64156d691fe5> in <module>
----> 1 import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'
The problem only exists inside jupyter notebook, outside the notebook the import works without any problem. I am running Python3.8 in Xubuntu, and I'm not using ananconda.
Create virtual environment and install Tensorflow
#Install virtualenv
sudo pip3 install virtualenv
#Create virtual environment name: venv
virtualenv venv
#Activate venv
source venv/bin/activate
#Install tensorflow
venv$ pip3 install tensorflow
#Install Jupyter notebook
venv$ pip3 install notebook
# Launch jupyter notebook
venv$ jupyter notebook
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.