I'm trying to use the yum Python package in CentOS 7.
In Python 2: I can successfully import yum
.
In Python 3: When I try to import yum
, I encounter ModuleNotFoundError: No module named 'yum'
.
The exact same issue occurs with the dnf Python package after I install dnf.
Researching around the issue took me to CentOS 8, where dnf
package does work on Python 3.
When trying to find python3-dnf
package (or the equivalent one for yum
) in CentOS 7.
Trying to install CentOS 8 packages on CentOS 7 only led me to conflicts and mismatches with required packages.
Also, trying to pip3 install yum
does not find any package, and pip3 install dnf
succeeds but importing gives the following warning:
/usr/local/lib/python3.6/site-packages/dnf.py:15: UserWarning: The DNF Python API is not currently available via PyPI.
Please install it with your distro package manager (typically called
'python2-dnf' or 'python3-dnf'), and ensure that any virtual environments
needing the API are configured to be able to see the system site packages
directory.
warnings.warn(warning_msg)
So, currently I can't find a way to interact natively with yum
/dnf
with Python code, running Python 3 on CentOS 7.