[Rpm-maint] Python bindings: ModuleNotFoundError on custom prefix

Jun Aruga jaruga at redhat.com
Tue Sep 12 09:31:28 UTC 2017

Hi Panu,
Thanks for the answer.

Um, "import rpm"?
> If that doesn't work then either it's not in your runtime environment
> paths, or there's something wrong with the build.

Yes, "import rpm".

> $ cd python/
>> $ python3 -m venv ./venv
> No idea what this does so hard to say.

It is the command to create Python's virtual environment (kind of another
clean python environment).
But sorry I missed to show the command to enable the virtual environment
"source venv/bin/activate" in the steps.

$ cd python/

$ python3 -m venv ./venv

$ source venv/bin/activate <= This.
(venv) $

Maybe it can't find the libraries of the newer rpm? strace is your friend,
> see what it's actually trying to do.
> There's also https://github.com/rpm-software-management/rpm/issues/130
> which might affect things but not sure that would manifest in this way.

OK, I will try on the way you introduced me.

Just in case, I would show the steps without virtual environment.

$ pwd

$ dest/bin/rpm --version
RPM version 4.14.90

$ cd python/

$ which python3

$ python3 setup.py build

$ sudo /usr/local/python-3.6.1/bin/python3 setup.py install

$ python3 -m pip list | grep '^rpm '
rpm                   4.14.90

$ python3 -c 'import rpm'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/jaruga/git/rpm/python/rpm/__init__.py", line 38, in <module>
    from rpm._rpm import *
ModuleNotFoundError: No module named 'rpm._rpm'

$ python3 -c 'import sys; print(sys.path)'
['', '/usr/local/python-3.6.1/lib/python36.zip',

$ ls /usr/local/python-3.6.1/lib/python3.6/site-packages/rpm | sort

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20170912/525dc6c8/attachment.html>

More information about the Rpm-maint mailing list