Mask_rcnn: ModuleNotFoundError: No module named 'imgaug'

Created on 2 Jun 2018  路  24Comments  路  Source: matterport/Mask_RCNN

I want to use Mask-RCNN demo.py in my jupyter notebook but when i ran the the demo code , i faced such a problem

ModuleNotFoundError Traceback (most recent call last)
in ()
19 # Import COCO config
20 sys.path.append(os.path.join(ROOT_DIR, "samples/coco/")) # To find local version
---> 21 import coco
22
23 get_ipython().run_line_magic('matplotlib', 'inline')

~/Mask_RCNN/samples/coco/coco.py in ()
32 import time
33 import numpy as np
---> 34 import imgaug # https://github.com/aleju/imgaug (pip3 install imageaug)
35
36 # Download and install the Python COCO tools from https://github.com/waleedka/coco

ModuleNotFoundError: No module named 'imgaug'

i can not solve my problem
can any body help me??
thank's

Most helpful comment

It gives this error after using pip install imgaug
Command "python setup.py egg_info" failed with error code 1 in C:\Users\NIDHIP~1\AppData\Local\Temp\pip-install-_m39k70w\Shapely\

      It gives this error after using pip install imgaug

Command "python setup.py egg_info" failed with error code 1 in C:\Users\NIDHIP~1\AppData\Local\Temp\pip-install-_m39k70w\Shapely
Same issue please do help..

It gives this error after using pip install imgaug
Command "python setup.py egg_info" failed with error code 1 in C:\Users\NIDHIP~1\AppData\Local\Temp\pip-install-_m39k70w\Shapely\

I am facing the same issue as @nidhipunj7 , @anitchris and @I2AI
Thanks in advance.

I was able to get it working after installing the wheel file from the website https://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely

Install the wheel file using pip while the virtual environment is active.

Once the Shapely is installed, run pip install imgaug.

Hope this helps.
Thank You.

All 24 comments

You need to _pip install imgaug_. If you are running the code using a virtual environment make sure you install the module within the virtual environment, meaning after you run _source activate_. That is because you need the PATH variable to be the same. Note the you might have to pip install other modules before like opencv.

thank you for your response
i use sodu pip install imgaug and get this:

(MaskRCNN) ubuntu@ubuntu:~/Downloads$ pip install imgaug
Collecting imgaug
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:777)'),)': /packages/d2/60/a06a48d85a7e9062f5870347a3e3e953da30b37928d43b380c949bca458a/imgaug-0.2.5.tar.gz
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:777)'),)': /packages/d2/60/a06a48d85a7e9062f5870347a3e3e953da30b37928d43b380c949bca458a/imgaug-0.2.5.tar.gz
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:777)'),)': /packages/d2/60/a06a48d85a7e9062f5870347a3e3e953da30b37928d43b380c949bca458a/imgaug-0.2.5.tar.gz
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:777)'),)': /packages/d2/60/a06a48d85a7e9062f5870347a3e3e953da30b37928d43b380c949bca458a/imgaug-0.2.5.tar.gz
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:777)'),)': /packages/d2/60/a06a48d85a7e9062f5870347a3e3e953da30b37928d43b380c949bca458a/imgaug-0.2.5.tar.gz
Could not install packages due to an EnvironmentError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Max retries exceeded with url: /packages/d2/60/a06a48d85a7e9062f5870347a3e3e953da30b37928d43b380c949bca458a/imgaug-0.2.5.tar.gz (Caused by SSLError(SSLError(1, '[SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:777)'),))

and then i run the demo.py i faced previous Error

Are you on a office network with office proxy or firewall?

I am at the university

Well, the problem is that you cant connect to the pip server. Try a different wifi (hotspot perhaps), or download imgaug and install directly.

"Alternatively, you can download the repository via git clone https://github.com/aleju/imgaug and install by using python setup.py sdist && sudo pip install dist/imgaug-0.2.5.tar.gz."

from https://github.com/aleju/imgaug

thanks for your great help This problem has been resolved i have new problem when i ran the demo code i faced such a problem
OSError Traceback (most recent call last)
in ()
3
4 # Load weights trained on MS-COCO
----> 5 model.load_weights(COCO_MODEL_PATH, by_name=True)

~/Mask_RCNN/mrcnn/model.py in load_weights(self, filepath, by_name, exclude)
2102 if h5py is None:
2103 raise ImportError('load_weights requires h5py.')
-> 2104 f = h5py.File(filepath, mode='r')
2105 if 'layer_names' not in f.attrs and 'model_weights' in f:
2106 f = f['model_weights']

~/anaconda3/envs/MaskRCNN/lib/python3.6/site-packages/h5py/_hl/files.py in __init__(self, name, mode, driver, libver, userblock_size, swmr, *kwds)
310 with phil:
311 fapl = make_fapl(driver, libver, *
kwds)
--> 312 fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr)
313
314 if swmr_support:

~/anaconda3/envs/MaskRCNN/lib/python3.6/site-packages/h5py/_hl/files.py in make_fid(name, mode, userblock_size, fapl, fcpl, swmr)
140 if swmr and swmr_support:
141 flags |= h5f.ACC_SWMR_READ
--> 142 fid = h5f.open(name, flags, fapl=fapl)
143 elif mode == 'r+':
144 fid = h5f.open(name, h5f.ACC_RDWR, fapl=fapl)

h5py/_objects.pyx in h5py._objects.with_phil.wrapper()

h5py/_objects.pyx in h5py._objects.with_phil.wrapper()

h5py/h5f.pyx in h5py.h5f.open()

OSError: Unable to open file (truncated file: eof = 74436151, sblock->base_addr = 0, stored_eof = 257557808)
i serch this in google and find this:
"I ran into this problem because I had accidentally terminated the download of the keras model data file before it was done, making it unreadable by h5py. I went into .keras/models/ and deleted the data file so that keras would re-download it."
but i am in ubuntu 18.04, there is NO model folder under .keras
there is only one file inside .keras which is keras.json!!!!!
please help me
i am sorry for my weak english grammar

Have you installed the correct package versions specified in the requirements.txt?

yes i have installed them one by one with conda install... .
numpy
scipy
cython
h5py
Pillow
scikit-image
tensorflow-gpu==1.5
keras
jupyter
all of them i have installed

any updates?

hello do you try
pip3 install git+https://github.com/aleju/imgaug

?

i faced the "ImportError" problem, too. when run the demo.py . But the message is

Traceback (most recent call last):
File "demo.py", line 12, in
import coco
File "/home/t00345175/Mask_RCNN-master/samples/coco/coco.py", line 47, in
import urllib.request
ImportError: No module named request

Does anyone knows how to handle it ?

i faced the "ImportError" problem, too. when run the demo.py . But the message is

Traceback (most recent call last):
File "demo.py", line 12, in
import coco
File "/home/t00345175/Mask_RCNN-master/samples/coco/coco.py", line 47, in
import urllib.request
ImportError: No module named request

Does anyone knows how to handle it ?

@tTianyu
which python version are you using? Make sure it is Python 3.6. Urllib is standard library in python3

It gives this error after using pip install imgaug
Command "python setup.py egg_info" failed with error code 1 in C:\Users\NIDHIP~1\AppData\Local\Temp\pip-install-_m39k70w\Shapely\

      It gives this error after using pip install imgaug

Command "python setup.py egg_info" failed with error code 1 in C:\Users\NIDHIP~1\AppData\Local\Temp\pip-install-_m39k70w\Shapely\
Same issue please do help..

Same issue as anitchris. Please help

It gives this error after using pip install imgaug
Command "python setup.py egg_info" failed with error code 1 in C:\Users\NIDHIP~1\AppData\Local\Temp\pip-install-_m39k70w\Shapely\

      It gives this error after using pip install imgaug

Command "python setup.py egg_info" failed with error code 1 in C:\Users\NIDHIP~1\AppData\Local\Temp\pip-install-_m39k70w\Shapely
Same issue please do help..

It gives this error after using pip install imgaug
Command "python setup.py egg_info" failed with error code 1 in C:\Users\NIDHIP~1\AppData\Local\Temp\pip-install-_m39k70w\Shapely\

I am facing the same issue as @nidhipunj7 , @anitchris and @I2AI
Thanks in advance.

It gives this error after using pip install imgaug
Command "python setup.py egg_info" failed with error code 1 in C:\Users\NIDHIP~1\AppData\Local\Temp\pip-install-_m39k70w\Shapely\

      It gives this error after using pip install imgaug

Command "python setup.py egg_info" failed with error code 1 in C:\Users\NIDHIP~1\AppData\Local\Temp\pip-install-_m39k70w\Shapely
Same issue please do help..

It gives this error after using pip install imgaug
Command "python setup.py egg_info" failed with error code 1 in C:\Users\NIDHIP~1\AppData\Local\Temp\pip-install-_m39k70w\Shapely\

I am facing the same issue as @nidhipunj7 , @anitchris and @I2AI
Thanks in advance.

I was able to get it working after installing the wheel file from the website https://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely

Install the wheel file using pip while the virtual environment is active.

Once the Shapely is installed, run pip install imgaug.

Hope this helps.
Thank You.

Thanks Nikhil, that fixed my problem!

I was able to get it working after installing the wheel file from the website https://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely

Install the wheel file using pip while the virtual environment is active.

You can also install shapely from anaconda navigator.

It gives this error after using pip install imgaug
Command "python setup.py egg_info" failed with error code 1 in C:\Users\NIDHIP~1\AppData\Local\Temp\pip-install-_m39k70w\Shapely\

      It gives this error after using pip install imgaug

Command "python setup.py egg_info" failed with error code 1 in C:\Users\NIDHIP~1\AppData\Local\Temp\pip-install-_m39k70w\Shapely
Same issue please do help..

It gives this error after using pip install imgaug
Command "python setup.py egg_info" failed with error code 1 in C:\Users\NIDHIP~1\AppData\Local\Temp\pip-install-_m39k70w\Shapely\

I am facing the same issue as @nidhipunj7 , @anitchris and @I2AI
Thanks in advance.

I was able to get it working after installing the wheel file from the website https://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely

Install the wheel file using pip while the virtual environment is active.

Just adding a point to your explanation :)

Go to the https://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely website to download the corresponding wheel package, search for shapely directly on it, and then click on the corresponding platform and Python version.

For example:
my python3.6, win764 bit, then i downloaded shapely-1.6.4.post1-cp36-cp36m-win_amd64.whl

Once the Shapely is installed, run pip install imgaug.

Hope this helps.
Thank You.

It gives this error after using pip install imgaug
Command "python setup.py egg_info" failed with error code 1 in C:\Users\NIDHIP~1\AppData\Local\Temp\pip-install-_m39k70w\Shapely\

      It gives this error after using pip install imgaug

Command "python setup.py egg_info" failed with error code 1 in C:\Users\NIDHIP~1\AppData\Local\Temp\pip-install-_m39k70w\Shapely
Same issue please do help..

It gives this error after using pip install imgaug
Command "python setup.py egg_info" failed with error code 1 in C:\Users\NIDHIP~1\AppData\Local\Temp\pip-install-_m39k70w\Shapely\

I am facing the same issue as @nidhipunj7 , @anitchris and @I2AI
Thanks in advance.

I was able to get it working after installing the wheel file from the website https://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely

Install the wheel file using pip while the virtual environment is active.

Once the Shapely is installed, run pip install imgaug.

Hope this helps.
Thank You.

Running pip install shapely before pip install imgaug also works. Thank you so much!

The complete process to install imgaug is described in this article which works perfectly fine and this article will clear your related error as well. The link of that article is
Real-time image segmentation with MaskRCNN

solved by creating a new env on python 3.6 and then followed by the following official commands
conda config --add channels conda-forge
conda install imgaug
after that i installed all other dependencies

You need use python3 instead of python2.

Was this page helpful?
0 / 5 - 0 ratings