[英]Tensorflow module not found in jupyter
在我的 jupyter 笔记本上运行时:
!pip3 install tensorflow
我得到:
Requirement already satisfied: tensorflow in /home/bluegoblin/.virtualenvs/tf2Env/lib/python3.8/site-packages (2.3.1)
所以,这意味着我确实在我的虚拟环境中安装了 tensorflow。
但是当我尝试在同一笔记本上使用import tensorflow as tf
导入它时,我得到:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-5-64156d691fe5> in <module>
----> 1 import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'
问题仅存在于 jupyter notebook 内部,在 notebook 外部导入工作没有任何问题。 我在 Xubuntu 中运行 Python3.8,我没有使用 ananconda。
创建虚拟环境并安装 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.