首页 > 解决方案 > ModuleNotFoundError:没有名为“tensorflow”的模块。我应该怎么办?

问题描述

我尝试使用imageAI识别图像中的对象。我使用 pycharm,Windows 10 64 位,python 3.6.8。当我尝试运行我的程序时,会出现错误:

ModuleNotFoundError:没有名为“tensorflow”的模块

它与此字符串有关:import tensorflow as tf
我也可以发送图片 在此处输入图像描述

这是代码:

from imageai.Detection import ObjectDetection
import os

exec_path = os.getcwd()

detector = ObjectDetection()
detector.setModelTypeAsRetinaNet()
detector.setModelPath(os.path.join(
    exec_path, 'resnet50_coco_best_v2.0.1.h5')
)
detector.loadModel()

    list = detector.detectObjectsFromImage(
        input_image=os.path.join(exec_path, 'objects.jpg'),
        output_image_path=os.os.path.join(exec_path, 'new_objects.jpg')
    )

I have installed with pip tensorflow, pillow, numpy, matplotlib, h5py, keras, image ai, open_cv and scipy.

标签: pythontensorflowpippycharm

解决方案


按 Ctrl+Alt+S,然后检查 tensorflow 是否已添加到您的项目中。只需单击左侧的项目:您的项目名称,然后您将看到活动模块的列表。要添加新的,请单击右侧的加号按钮并找到 tensorflow 包。选择这个名字只有 tensorflow 的。单击安装包并稍等片刻。

我对 selenium 包也有同样的问题。我用 pip 安装了它,但对于 pycharm,使用它的管理器是一个更好的主意。


推荐阅读