简体   繁体   English

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

[英]ModuleNotFoundError: No module named 'utils.datasets'

I am using Python 3.6.8 on Windows 10我在 Windows 10 上使用 Python 3.6.8
I installed tensorflow, keras, and utils using pip .我使用pip安装了tensorflow、keras 和 utils

pip install tensorflow and it installs the version 2.0.0 pip install tensorflow并安装版本2.0.0
pip install keras and it installs the version 2.3.1 pip install keras并安装2.3.1版本
pip install utils but it does not show what version I have installed. pip install utils但它没有显示我安装的版本。

This is my header:这是我的标题:

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

This is my error:这是我的错误:

from utils.datasets import get_labels从 utils.datasets 导入 get_labels
ModuleNotFoundError: No module named 'utils.datasets' ModuleNotFoundError:没有名为“utils.datasets”的模块

Why am I getting this error?为什么我收到这个错误? And how to fix it?以及如何修复它? BTW The code was written by a previous programmer and I need to modify it. BTW 代码是以前的程序员写的,我需要修改它。 But I can't even run it.但我什至不能运行它。 not so good in python tho.在 python 中不太好。 i'm just getting started to it.我才刚刚开始。

All my google search are all purple but I can't seem to find any solutions.我所有的谷歌搜索都是紫色的,但我似乎找不到任何解决方案。

EDIT编辑

The suggested answer ( ImportError: No module named datasets ) does not satisfy my needs.建议的答案( ImportError: No module named datasets )不能满足我的需求。 I am having trouble on utils module.我在 utils 模块上遇到了问题。 because when I comment out the line from utils.datasets import get_labels因为当我from utils.datasets import get_labels

The error is on the next line:错误在下一行:

ModuleNotFoundError: No module named 'utils.inference' ModuleNotFoundError:没有名为“utils.inference”的模块

The utils model what the code your provided want to import is the part of theoarriaga/face_classification project.您提供的代码想要导入的 utils 模型是oarriaga/face_classification项目的一部分。

The pip installed utils modul is quite different package, so you should not have installed via pip . pip 安装的utils模块是完全不同的包,所以你不应该通过pip安装。 Your code try to import moduls from this package, but it obviously has no such moduls.您的代码尝试从这个包中导入模块,但它显然没有这样的模块。 That is why the error messages.这就是错误消息的原因。

So what you have to do is pip uninstall utils and then if your project directory structure is complete, the above code will import the face_classification package's moduls.所以你要做的就是pip uninstall utils ,然后如果你的项目目录结构完整,上面的代码就会导入face_classification包的模块。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM