ModuleNotFoundError: No module named 'utils' - python

I'm trying to run the object_detection API in Tensorflow using my webcam as an input.
The error says: "from utils import label_map_util ModuleNotFoundError: No module named 'utils'"
Which relates to the lines:
from utils import label_map_util
from utils import visualization_utils as vis_util
I've tried "pip install util" appears to work but doesn't solve the problem. I have also reinstalled multiple versions of protobuf as other questions online appear to have this as the solution. I don't get any errors when I install protoc so I don't think this is the issue.
I'm using python 3.6 on windows 10 with tensorflow-gpu.

add object_detection to the front of utils:
# from utils import label_map_util
# from utils import visualization_utils as vis_util
from object_detection.utils import label_map_util
from object_detection.utils import visualization_utils as vis_util

What folder are you running your python script from?
To be able to access the 'utils' module directly, you need to be running the script inside the <models-master>\research\object_detection folder.

Instead of running script inside object detection folder append the
path of tensorflow object detection in your script by writing
import sys
sys.path.append('PATH_TO_TENSORFLOW_OBJECT_DETECTION_FOLDER')
e.g 'PATH_TO_TENSORFLOW_OBJECT_DETECTION_FOLDER' in my ubuntu system is
/home/dc-335/Documents/Softwares/tensorflow/models/research/object_detection
Cheers, You done it !!

I used a quicker method to fix it.
I copied the utils folder from models\research\object_detection and pasted it within the same directory as the python file which required utils

the installation didn't go through, you will notice no module called model_utils in your project folder.
uninstall it pip uninstall django-model-utils then install it again pip install django-model-utils a new app called model_utils in your project folder.

I used to quick method
!pip install utils
it workes properlly

Related

No module named 'lstm_object_detection' in tensorflow /model/research/lstm_object_detection

I gitcloned lstm from tensorflow research models. Running seq_dataset_builder.py from inputs file the following error appears
No module named 'lstm_object_detection'.
The line making the error is
from lstm_object_detection.inputs import tf_sequence_example_decoder
lstm_object_detection/inputs is the directory of the python script file.
My tensorflow version is 1.7.0 and the file is run on python3.
I also can't import tensorflow.google.
Thanks in advance.
It might be that Python doesn't find the lstm_object_detection in your path
import os
import sys
sys.path.append(os.getcwd()) # add current directory to your path
from lstm_object_detection.inputs import tf_sequence_example_decoder
To check the paths where Python looks for modules use:
import sys
for path in sys.path:
print(path)

AttributeError: module 'utils' has no attribute 'load_data'

I am engaging a project now, and the library utils might be frequently used. However, I encounter a problem
import numpy as np
import pandas as pd
import featuretools as ft
import utils
data_path = 'dataturbo/train_FD003.txt'
data = utils.load_data(data_path)
data.head()
how to solve this guys, i'm always encountering this problem
For those who wants to know the solution. I believe he is testing a package from FeatureTools.
https://github.com/Featuretools/predict-remaining-useful-life
import utils package is not something you install from conda or pip install, but a utils.py script you can download from FeatureTools github page.

Installed the google-cloud-storage module 0.22.0, Imports fine by itself but not as an import of an import

I install the google cloud storage module via pip. It imports fine as a standalone.
>>> import google.cloud.storage
It imports fine if the import is in the file I'm running on. It doesn't import if I import a file from another module that's import it.
python dag.py list_tasks
File "/home/test/hecks/airflow-dags/dags/extract/api_extract.py", line 3, in <module>
from google.cloud.storage import Client
ImportError: No module named cloud.storage
Duplicate module names. Conflicted with the installed package.

Python ImportError: cannot import name datafunc [PyML]

I have installed PyML package in order to use some machine learning algorithms, and according to the tutorial, my installation is successful.
I try to run a python script which includes the following line to import modules from PyML
from PyML import datafunc,svm,assess,modelSelection,ker
However I get the error message above saying
File <stdin>, line 1, in <module> ImportError: cannot import name
datafunc
cannot import name datafunc`. From terminal I check every module by saying
from PyML import datafunc,
from PyML import svm,
from PyML import ker
I only get error message for datafunc. The PyML library is under the site-packages folder of Python 2.7.
I check this question here Python error: ImportError: cannot import name Akismet, but I could't see how it will help my problem.
Do you have any idea why Python imports some modules but does not import this one?
In PyML-0.7.13.3, the datafunc module exists in PyML/containers directory.
So it seems that you can import the module as follows:
from PyML.containers import datafunc
Howerver, it raises an error beacuse the datafunc module uses
undefined classes BaseVectorDataSet and SparseDataSet.
Thus you need to modify the source of PyML
in order to use datafunc module.
First, prepend the following two lines to PyML/containers/datafunc.py
and re-install the PyML library.
from PyML.containers.baseDatasets import BaseVectorDataSet
from PyML.containers.vectorDatasets import SparseDataSet
Then you can import the modules as follows:
from PyML import svm, modelSelection, ker
from from PyML.containers import datafunc
from from PyML.evaluators import assess
BTW, I recommend that you use more documented and tested machine learning library, such as scikit-learn.

iPython: 'no module named' ImportError

Windows: I have the Python package CVXOPT installed on my computer for the regular Python distribution, though not specifically with Anaconda, so it imports fine when I'm doing text editor/cmd python scripting. I tried installing CVXOPT with Anaconda, but that didn't work so I'm having to import the library directly when working with iPython.
My directory structure looks like:
C:
--Python27
----Lib
------site-packages
--------cvxopt
----------__init__.py
----------.....
The error occurs when I run this code in an iPython notebook:
import sys
sys.path.append('C:\Python27\Lib\site-packages\cvxopt')
import cvxopt
The error:
ImportError: No module named cvxopt
How can I fix this? Perhaps I'm appending the path incorrectly?
You're defining a path a bit too deep in your file tree. You need to add to sys.path the folder just before your module:
import sys
sys.path.append('C:\Python27\Lib\site-packages')
import cvxopt
Here, cvxopt can be found in the site-packages folder. If you add the cvxopt folder in the sys path, it'll search a module of that name in the folder itself and will not checked the base folder.
Import the path which contains the cvxopt package.
import sys
sys.path.append('C:\Python27\Lib\site-packages')
import cvxopt

Categories