ModuleNotFoundError: No module named 'utils.datasets' - python

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'

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.

Related

Can't import VecFrameStackFrame from Stable-baselines3 - importing problem

I have a problem when importing some dependencies from stable baselines 3 library, I installed it with this command
pip install stable-baselines3[extra]
But When I import my dependencies
import gym
from stable_baselines3 import A2C
from stable_baselines3.common.vec_env import VecFrameStackFrame
from stable_baselines3.common.evaluation import evaluate_policy
from stable_baselines3.common.env_util import make_atari_env
import os
I face this error
ImportError: cannot import name 'VecFrameStackFrame' from 'stable_baselines3.common.vec_env' (C:\Users\User\anaconda3\envs\rl_learning\lib\site-packages\stable_baselines3\common\vec_env\__init__.py)
Any advice?
I knew that stable baselines new version has changed the name from
from stable_baselines3.common.vec_env import VecFrameStackFrame
To
from stable_baselines3.common.vec_env import vec_frame_stack
and it worked for me

Cannot import umap: cannot import name 'structref' from 'numba.experimental'

I tried to import umap in my jupyter notebook but had the following error:
ImportError: cannot import name 'structref' from 'numba.experimental' (C:\Users\name\Anaconda3\lib\site-packages\numba\experimental\__init__.py)
I tried to update conda but doesn't work. What can I do ?
The numba.experimental subpackage was added in version 0.51.0. You can check your version of number using:
import numba
numba.__version__
If it is less then 0.51.0, you will need to install a newer version.
conda install numba=0.51.*

ImportError: cannot import name 'types' Even though I installed google-cloud

I am making a program right now and I am failing at the imports. I am just importing google.cloud.vision and from google.cloud.vision I am importing types as my code
import os, io
from google.cloud import vision
from google.cloud.vision import types
says. I am not getting an error when installing google.cloud in the second line but only at the third line and I don't know why since I am not failing at the second line? I already installed both google-cloud and google-cloud-vision using pip install google-cloud and pip install google-cloud-vision
I believe types is in the vision_v1 namespace. Try the following:
from google.cloud.vision_v1 import types
https://googleapis.dev/python/vision/latest/vision_v1/types.html

ModuleNotFoundError no module named 'tensorflow' when running script from command line windows

I' trying to run script from command line that classify images.
When I run script from Pycharm terminal it works properly, but when I'm trying to run from command line there is error:
File "process.py", line 3, in <module>
import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'
There are several first lines of script:
import os
import tensorflow as tf
import numpy as np
import json
How can I fix this error?
The path of the tenserflow module may not be in the paths for searching modules in your python installation. You will have to explicitly add the path of the tenserflow module to your process.py file by
import sys
sys.path.insert(1, "<path to tenserflow module>")
import tenserflow as tf
The code may be working in pycharm because the path of tenserflow module may be in the module search directories of pycharm.
pip install tensorflow
OR
pip3 install tensorflow
in terminal/cmd
If you are using a virtualenv/venv/anaconda, you will need to activate it

TensorFlow Object Detection API and utils module

I am just starting with TensorFlow and came across the TensorFlow Object Detection API tutorial. I have followed the installation steps outlined in the first section, created a new conda virtual environment (within Visual Studio 2017) and installed TensorFlow using pip. Also I have installed the packages listed in the other sections.
This are the imports taken from here: Detect Objects Using Your Webcam
import numpy as np
import os
import six.moves.urllib as urllib
import sys
import tarfile
import tensorflow as tf
import zipfile
import cv2
from collections import defaultdict
from io import StringIO
from matplotlib import pyplot as plt
from PIL import Image
from utils import label_map_util
from utils import visualization_utils as vis_util
However it can't find the a package/module called utils. Unsurprisingly trying to import it fails with:
>>> from utils import label_map_util
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'utils'
So what kind of module is this and where can I get it from?
Add the root directory of Object Detection API ( ...\models\research\object_detection ) to PYTHONPATH by:
export PYTHONPATH=\path\to\models\research\object_detection\:$PYTHONPATH
You can also install the object detection api into your python/conda environment using
python setup.py build
python setup.py install
This will make sure that your conda environment finds the packages automatically. The setup.py file is in the models/research folder.

Categories