python - 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.
解决方案
按 Ctrl+Alt+S,然后检查 tensorflow 是否已添加到您的项目中。只需单击左侧的项目:您的项目名称,然后您将看到活动模块的列表。要添加新的,请单击右侧的加号按钮并找到 tensorflow 包。选择这个名字只有 tensorflow 的。单击安装包并稍等片刻。
我对 selenium 包也有同样的问题。我用 pip 安装了它,但对于 pycharm,使用它的管理器是一个更好的主意。
推荐阅读
- reactjs - 使用 React Router 时传递状态的最简单方法是什么?
- python - 在具有 GPU 支持的 Tensorflow 中创建自定义 LSTMCell
- java - 试图限制基于图块的游戏中的移动
- mysql - 如何将索引添加到 mysql 数据库以提高性能?
- mysql - 如何从 MySQL 表中的列中删除以某些特定单词开头和结尾的部分文本/段落?
- assembly - 你如何在 SSE2 上进行带符号的 32 位扩展乘法?
- python - 根据 1-2 个公共键值获取 4 个 JSON 文件的交集?(Python)
- python - 用列名填充 NaN 的 Python Dataframe 问题
- floating-point - 为什么从 int 到 float “可以四舍五入”,但从 int 到 double “可以保留”?
- command-line-interface - 为部署和开发环境交换变量的独立于框架的方法