3

I am using Python 3.6.8 on Windows 10
I installed tensorflow, keras, and utils using pip.

pip install tensorflow and it installs the version 2.0.0
pip install keras and it installs the version 2.3.1
pip install utils but it does not show what version I have installed.

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
ModuleNotFoundError: No module named '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. But I can't even run it. not so good in python tho. 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. I am having trouble on utils module. because when I comment out the line from utils.datasets import get_labels

The error is on the next line:

ModuleNotFoundError: No module named 'utils.inference'

SecretAgentMan
  • 2,856
  • 7
  • 21
  • 41
kiLLua
  • 443
  • 1
  • 6
  • 17
  • Does this answer your question? [ImportError: No module named datasets](https://stackoverflow.com/questions/42319101/importerror-no-module-named-datasets) – abhikumar22 Dec 04 '19 at 04:24
  • @abhikumar22 no it does not. My error is from `utils.datasets` module not on `datasets` module. That's what I thought – kiLLua Dec 04 '19 at 04:48
  • then try to reinstall it – abhikumar22 Dec 04 '19 at 04:53
  • I've already done it many times T_T I've also tried to reinstall everything including `pyhton` – kiLLua Dec 04 '19 at 04:57
  • Utils is not a standard package, it is specific to the code you are trying to run, what exact code is this? – Dr. Snoopy Dec 04 '19 at 07:36
  • @MatiasValdenegro It is for emotion detection. do you have a link how to use utils? – kiLLua Dec 04 '19 at 09:53
  • 1
    You did not understand my comment, utils is a package specific to your code, you have to tell us what it is, not us. Its probably a package inside your source code (which we do not have). – Dr. Snoopy Dec 04 '19 at 09:54

1 Answers1

4

The utils model what the code your provided want to import is the part of the oarriaga/face_classification project.

The pip installed utils modul is quite different package, so you should not have installed via 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.

Geeocode
  • 5,705
  • 3
  • 20
  • 34
  • I found `utils` folder in the directory. thanks! i did uninstall utils and now it's working. I am just having trouble with the deprecated codes in the package. – kiLLua Dec 05 '19 at 01:50