ModuleNotFoundError: 未找到名为’utils.datasets’的模块

我在Windows 10上使用Python 3.6.8
我使用pip安装了tensorflow, keras 和 utils

pip install tensorflow 安装了版本 2.0.0
pip install keras 安装了版本 2.3.1
pip install utils 但它没有显示我安装的版本。

这是我的头部代码:

from keras.preprocessing import imagefrom PIL import Imagefrom keras.models import model_from_json, load_modelimport numpy as npimport cv2from datetime import datetimeimport osimport randomimport stringfrom utils.datasets import get_labelsfrom utils.inference import apply_offsetsfrom utils.inference import load_detection_modelfrom utils.preprocessor import preprocess_input

这是我的错误:

from utils.datasets import get_labels
ModuleNotFoundError: 未找到名为’utils.datasets’的模块

为什么我会得到这个错误?如何修复它?顺便说一下,这段代码是由之前的程序员编写的,我需要修改它。但我连运行都做不到。我对Python不太熟练,我才刚开始学。

我在谷歌上搜索的所有链接都已经变紫色了,但我似乎找不到任何解决方案。

编辑

建议的答案(ImportError: No module named datasets)不符合我的需求。我在utils模块上遇到了麻烦。因为当我注释掉from utils.datasets import get_labels这一行时

错误出现在下一行:

ModuleNotFoundError: 未找到名为’utils.inference’的模块


回答:

你提供的代码想要导入的utils模块是oarriaga/face_classification项目的一部分。

通过pip安装的utils模块是一个完全不同的包,所以你不应该通过pip安装。你的代码试图从这个包中导入模块,但显然它没有这些模块。这就是错误信息出现的原因。

所以你需要做的是pip uninstall utils,然后如果你的项目目录结构是完整的,上述代码将导入face_classification包的模块。

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注