Search code examples
pythonpycharmcythonface-detectionfaster-rcnn

No module named 'bbox'


I am working on one project which should be re written, so i did not write from beginning, and there is no opportunity to ask person who wrote the code.

I have next part of code:

from ..cython.bbox import bbox_overlaps_cython

def bbox_overlaps(boxes, query_boxes):
    return bbox_overlaps_cython(boxes, query_boxes)

Then this error comes out:

from ..cython.bbox import bbox_overlaps_cython
ModuleNotFoundError: No module named 'lib.rcnn.cython.bbox'

I already tried to build like python3 setup.py build_ext --inplace in the same directory where setup.py is located, but error is the same.

The tree of folders is next:

rcnn

--cython

----bbox.pyx

----setup.py

--processing

----bbox_transform.py


Solution

  • It's difficult to propose a solution without knowing more about your environment and how you're invoking the code that throws the error.

    Like any module, that bbox module needs to be installed into your environment and also visible to the Python runtime when you invoke your code. At least one of these things is not as it should be.

    • Is the bbox module installed into your environment? What is in that setup.py?
    • How are you invoking the code? From which directory?

    The import from ..cython.bbox import bbox_overlaps_cython uses a relative path to find the bbox module, so it makes an assumption about the location of the module relative to the file where the import happens.

    You might find that invoking the code from the directory above or below solves the problem. Or, assuming that the module is present and correct in one of those directories, you might be able to add the location of the bbox module to the PYTHONPATH so that the import statement knows where to find it at runtime.