Fabio Araujo
Fabio Araujo

Reputation: 379

ImportError: No module named <module name> module inside folder

I'm importing files from the following folder inside a python code:

Mask_RCNN
  -mrcnn
    -config.py
    -model.py
    -__init__.py
    -utils.py
    -visualize.py

I'm using the following imports:

These work ok: from Mask_RCNN.mrcnn.config import Config from Mask_RCNN. mrcnn import utils

These give me error:

from Mask_RCNN.mrcnn import visualize
import mrcnn.model as modellib

Error:

ImportError: No module named 'mrcnn'

How to import these properly?

Upvotes: 3

Views: 5507

Answers (2)

Subiksha Baskar
Subiksha Baskar

Reputation: 11

Use this line before importing the libraries

sys.path.append("Mask_RCNN/") 

Upvotes: 1

illesguy
illesguy

Reputation: 46

You get an error for the 2nd import, where you omit Mask_RCNN from the package name.

Try changing the lines to:

from Mask_RCNN.mrcnn import visualize
import Mask_RCNN.mrcnn.model as modellib

Upvotes: 2

Related Questions