我使用 conda 创建了一个虚拟环境,然后在该环境中安装了 tensorflow。我可以在运行交互式 python shell 时导入它。但是,我无法在 jupyter notebook 中导入 tensorflow 模块。
问问题
280 次
3 回答
1
You need install Jupyter into same environment. Activate the environment with tensorflow and:
conda install jupyter
to make sure you use the corresponding jupyter start with:
python -m jupyter notebook
于 2018-03-09T16:00:09.020 回答
0
正如大卫所说,你可能在你的机器上安装了两个 python,sys.path
从终端和笔记本的环境中检查,理想情况下它们应该指向你的本地环境。要在本地环境中使用 jupyter notebook,请安装它并使用运行内核
python -m jupyter notebook
于 2020-11-30T08:23:51.423 回答
0
你的盒子上可能有两个 python 安装。运行笔记本时,运行以下命令:
import sys
print(sys.path)
接着
import os
print(os.environ['PATH'])
print(os.environ['PYTHONPATH'])
确保它们指向您安装 tensorflow 的位置。您可以通过从命令行运行来检查安装 tensorflow 的位置:
pip show -f tensorflow
或从外壳运行:
import tensorflow
tensorflow.__file__
于 2018-03-09T15:50:32.543 回答