Why can't Python find this shared object I'm trying to relative import despite it existing in the same folder?

30 Views Asked by At

I have a file __init__.py with the following import:

from ._nms import lib as _lib, ffi as _ffi

where _nms.so is a shared object in the same directory as this Python file.

Relevant file structure is as follows (also see this repo, which this project is a clone of):

├───nms
│   │
│   ├───_ext
│   │   │   __init__.py
│   │   │
│   │   ├───nms
│   │   │   │   _nms.so
│   │   │   │   __init__.py

Trying to run the main.py script from the parent folder of the first nms folder of the above directory structure results in this error:

Traceback (most recent call last):
  File "main.py", line 43, in <module>
    import model as modellib
  File "C:\proj\model.py", line 26, in <module>
    from nms.nms_wrapper import nms
  File "C:\proj\nms\nms_wrapper.py", line 11, in <module>
    from nms.pth_nms import pth_nms
  File "C:\proj\nms\pth_nms.py", line 2, in <module>
    from ._ext import nms
  File "C:\proj\nms\_ext\nms\__init__.py", line 2, in <module>
    from ._nms import lib as _lib, ffi as _ffi
ModuleNotFoundError: No module named 'nms._ext.nms._nms'

I tried changing the shared object's name and import fearing that it might be an issue with "overusing" the nms name, but to no avail. I'd appreciate any insight into this. I will add that I'm trying to run this on a Windows 10 machine and I also (notably) had to downgrade some libraries such as pytorch (downgraded to 0.4.1) because of the original repo's lack of maintenance. Thank you for your help!

0

There are 0 best solutions below