【发布时间】:2017-11-12 08:03:01
【问题描述】:
我正在尝试在 jupyter notebook 上运行 tensorflow。我通过这样做在 tensorflow 环境之外安装了 jupyter
sudo -H pip install jupyter
然后我通过
激活了tensorflow环境source ~/tensorflow/bin/activate
然后,当我在环境中时,我做到了
pip install jupyter notebook
之后,我运行了jupyter notebook,但是当我尝试导入tensorflow时,出现以下错误:
ImportError: No module named tensorflow
我检查了jupyter是否通过运行识别环境
which jupyter
得到了
/usr/local/bin/jupyter
这意味着它没有识别环境。如何强制 jupyter 识别环境? (正如我提到的,我也确实在环境中安装了 jupyter)
编辑:我只是想澄清一下 tensorflow 确实已正确安装在我的机器上(例如,我可以在 pycharm 中使用它,也可以在我刚从 shell 打开 python 时使用它)。
Edit2:作为对@hek2mgl 评论的回应,这是我得到的:
username@blabla:~$ source ~/tensorflow/bin/activate
(tensorflow) username@blabla:~$ pip install jupyter
(tensorflow) username@blabla:~$ which jupyter
/usr/local/bin/jupyter
(tensorflow) username@blabla:~$ hash -d
hits command
1 /usr/bin/which
1 /home/local/bla/username/tensorflow/bin/pip
(tensorflow) username@blabla:~$ which jupyter
/usr/local/bin/jupyter
【问题讨论】:
-
你需要在同一个virtualenv中安装tensorflow和jupyter
-
谢谢。当我在环境中时,我运行“pip install jupyter notebook”,但它不起作用。我需要做其他事情吗?
-
运行
hash -d。然后再次运行which jupyter -
@hek2mgl,谢谢。我添加了这一行,并编辑了问题以显示我得到了什么。
-
激活命令后运行
pip install jupyter然后再次运行hash -d
标签: python linux ubuntu tensorflow jupyter