gpt4 book ai didi

python - 为什么jupyter的对象检测演示显示它无法导入tensorflow?

转载 作者:行者123 更新时间:2023-12-01 07:38:19 28 4
gpt4 key购买 nike

我正在关注这个 tensorflow 教程 https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/install.html#protobuf-installation-compilation我在测试安装时遇到一些问题。

我在教程中安装了除 COCO API 之外的所有内容,并且现在正在 jupyter 中运行对象检测演示。由于某种原因,我在笔记本内收到一个错误,告诉我“没有名为‘tensorflow’的模块”。我仍然可以单击“全部运行”还是必须修复此错误?

谢谢! :)

import numpy as np
import os
import six.moves.urllib as urllib
import sys
import tarfile
import tensorflow as tf
import zipfile

from distutils.version import StrictVersion
from collections import defaultdict
from io import StringIO
from matplotlib import pyplot as plt
from PIL import Image

# This is needed since the notebook is stored in the object_detection folder.
sys.path.append("..")
from object_detection.utils import ops as utils_ops

if StrictVersion(tf.__version__) < StrictVersion('1.12.0'):
raise ImportError('Please upgrade your TensorFlow installation to v1.12.*.')

---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-34f5cdda911a> in <module>
4 import sys
5 import tarfile
----> 6 import tensorflow as tf
7 import zipfile
8

ModuleNotFoundError: No module named 'tensorflow'

好的,由于某些原因,我现在收到此错误:

---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-34f5cdda911a> in <module>
10 from collections import defaultdict
11 from io import StringIO
---> 12 from matplotlib import pyplot as plt
13 from PIL import Image
14

ModuleNotFoundError: No module named 'matplotlib'

最佳答案

您可能面临计算机上安装了双版本 Python 的问题。 Jupyter 正在尝试编译 Tensorflow 教程文件,但使用了错误的内核(应该是 Python 3)。当我尝试运行包含 Tensorflow 的 ipynb 文件时,也发生了同样的情况。

所以我首先建议您执行以下操作:

  1. 在命令行中检查此命令的输出:

    jupyter 内核规范列表

  2. 然后它应该输出类似这样的内容:(如果是 Windows 操作系统)

    python3 c:\python 3.6.8\share\jupyter\kernels\python3

  3. 如果您发现“python2”或任何其他类型的版本,您应该手动删除它或尝试使用以下命令:

    jupyter kernelspec 删除 python_wrong_version

最后,如果问题仍然存在,您还可以检查链接https://github.com/jupyter/notebook/issues/397以便进一步讨论。

关于python - 为什么jupyter的对象检测演示显示它无法导入tensorflow?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56860432/

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