ModuleNotFoundError:没有名为“ utils.datasets”的模块

时间:2019-12-04 04:07:44

标签: python tensorflow machine-learning keras

我正在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 image
from PIL import Image
from keras.models import model_from_json, load_model
import numpy as np
import cv2
from datetime import datetime
import os
import random
import string

from utils.datasets import get_labels
from utils.inference import apply_offsets
from utils.inference import load_detection_model
from utils.preprocessor import preprocess_input

这是我的错误:

  

从utils.datasets导入get_labels
     ModuleNotFoundError:没有名为“ utils.datasets”的模块

为什么会出现此错误?以及如何解决?顺便说一句,代码是由以前的程序员编写的,我需要对其进行修改。但是我什至不能运行它。在python中不太好。我才刚刚开始。

我所有的google搜索都是紫色的,但是我似乎找不到任何解决方案。

编辑

建议的答案(ImportError: No module named datasets)无法满足我的需求。我在utils模块上遇到麻烦。因为当我注释行from utils.datasets import get_labels

错误在下一行:

  

ModuleNotFoundError:没有名为“ utils.inference”的模块

1 个答案:

答案 0 :(得分:0)

utils模型可以为您提供的代码导入oarriaga/face_classification项目的一部分。

安装的utils模块的点数非常不同包,因此您不应该通过pip安装。您的代码尝试从此包中导入模块,但显然没有此类模块。这就是错误消息的原因。

因此,您需要做的是pip uninstall utils,然后,如果您的项目目录结构完整,则上面的代码将导入face_classification包的模块。