我正在使用Jupyter笔记本,我正在尝试导入tensorflow。我得到的错误是:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-15-64156d691fe5> in <module>()
----> 1 import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'
我在虚拟环境中键入jupyter notebook
来托管笔记本:
(labs) Sahands-MBP:part1 sahandzarrinkoub$ jupyter notebook
tensorflow肯定安装在虚拟环境中:
(labs) Sahands-MBP:part1 sahandzarrinkoub$ python
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 12:04:33)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
>>>
为什么没找到?jupyter在哪里寻找包裹?我甚至在我的virtualenv之外安装了tensorflow。感谢你的帮助。
似乎您正在尝试使用来自您的基本Python的Jupyter安装,即在您的
labs
虚拟环境之外。解决这个问题的一个快速而简单的方法是在虚拟环境中另外安装Jupyter
从内部
labs
。为了避免多个Jupyter安装(在每个虚拟环境中),一种更通用的方法是使用Jupyter kernels;请参阅我的detailed answer here以了解PySpark的情况,这很容易适应您的情况。
可能是你的Jupyter笔记本正在寻找一个不同的路径,而不是你安装tensorflow的地方。您需要确保Jupyter通过正确的内核打开正确的Python。 解决此问题的一种方法是在终端中键入以下内容来安装nb-conda:
然后可以运行Jupyter,当从New下拉菜单中选择一个笔记本时,确保选择了连接到所需内核的Python(拥有所有库和依赖项的内核,如tensorflow)
相关问题 更多 >
编程相关推荐