Relative import cannot find .so submodule?

Paul Moore p.f.moore at gmail.com
Mon Jan 13 11:10:47 EST 2020


Did you build the extension as a debug build, but you're trying to use
it in a release build Python? That may not work (it may depend on the
OS, I don't know the compatibility details on MacOS)...

On Mon, 13 Jan 2020 at 16:02, Pieter van Oostrum
<pieter-l at vanoostrum.org> wrote:
>
> Patrick Stinson <patrickkidd at gmail.com> writes:
>
> > I have a module named rtmidi, and its C submodule named rtmidi/_rtmidi. The distills script builds successfully and successfully creates a build/lib dir with a rtmidi dir in it and the submodule file rtmidi/_rtmidi.cpython-36dm-darwin.so. I have set PYTHONPATH to this lib dir, but rtmidi/__init__.py gives the following error:
> >
> > Traceback (most recent call last):
> >   File "main.py", line 6, in <module>
> >     from pkmidicron import MainWindow, util, ports
> >   File "/Users/patrick/dev/pkmidicron/pkmidicron/__init__.py", line 1, in <module>
> >     from .mainwindow import *
> >   File "/Users/patrick/dev/pkmidicron/pkmidicron/mainwindow.py", line 2, in <module>
> >     import rtmidi
> >   File "/Users/patrick/dev/pkmidicron/pyrtmidi/build/lib/rtmidi/__init__.py", line 1, in <module>
> >     from ._rtmidi import *
> > ModuleNotFoundError: No module named 'rtmidi._rtmidi’
> >
> > How does the module finder work in the import system? I assume ti automatically resolves the name _rtmidi.cpython-36dm-darwin.so to _rtmidi? I didn’t have any luck reading the docs on the import system.
>
> Are you running python 3.6?
>
> I tried this on python 3.7 and it worked, but the file is called _rtmidi.cpython-37m-darwin.so there (37 for python3.7, and the d is missing, I don't know what that indicates).
> --
> Pieter van Oostrum
> www: http://pieter.vanoostrum.org/
> PGP key: [8DAE142BE17999C4]
> --
> https://mail.python.org/mailman/listinfo/python-list


More information about the Python-list mailing list