gpt4 book ai didi

python - 无法在 Jupyter Notebook 中导入 tensorflow

转载 作者:太空宇宙 更新时间:2023-11-04 08:36:03 25 4
gpt4 key购买 nike

我正在使用 Jupyter Notebook 并尝试导入 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,即

pip install jupyter

来自实验室

一个更通用的方法,也是为了避免多个 Jupyter 安装(在每个虚拟环境中),是使用 Jupyter kernels ;看我的 detailed answer here对于 PySpark 的情况,它很容易适应您的情况。

关于python - 无法在 Jupyter Notebook 中导入 tensorflow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48852696/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com