Fixed: subscription-manager, yum command failed with a python traceback error
Here is the recommended Solution from Access.RedHat.com Support Website:
https://access.redhat.com/solutions/7...
Comments
Helpful
Follow
subscription-manager, yum command failed with a python traceback error
SOLUTION IN PROGRESS - Updated September 21 2023 at 3:57 AM - English
Environment
Red Hat Enterprise Linux 9
Issue
yum failed with the following error on RHEL 9.
Raw
yum repolist
Traceback (most recent call last):
File "/usr/bin/yum", line 61, in module
from dnf.cli import main
ModuleNotFoundError: No module named 'dnf'
subscription-manager failed with the following error on RHEL 9.
Raw
subscription-manager status
Traceback (most recent call last):
File "/usr/lib64/python3.11/importlib/metadata/__init__.py", line 563, in from_name
return next(cls.discover(name=name))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
StopIteration
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/sbin/subscription-manager", line 33, in module
sys.exit(load_entry_point('subscription-manager==1.29.30', 'console_scripts', 'subscription-manager')())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/sbin/subscription-manager", line 22, in importlib_load_entry_point
for entry_point in distribution(dist_name).entry_points
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.11/importlib/metadata/__init__.py", line 981, in distribution
return Distribution.from_name(distribution_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.11/importlib/metadata/__init__.py", line 565, in from_name
raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: No package metadata was found for subscription-manager
Resolution
Follow the procedure in the Diagnostic Steps section.
If this is a match proceed as shown below.
Restore the default condition of the python environment, use the default version and Correct the symlink of python library path defined in the environment.
Raw
ln -s -f /usr/bin/python3.9 /usr/bin/python3
ls -lh /usr/bin/python*
Root Cause
Python 3.9 is the default Python implementation in RHEL 9.
The error happens when python symlink of library path is pointing to Python 3.11 or other version.
Diagnostic Steps
Verify that Python symbolic link is pointing to Python 3.9.
Raw
ls -lh /usr/bin/python*
Collect the following details from system .
Raw
rpm -Va Greather-Sign-Symbol-Here /tmp/rpm_va.txt
rpm -qa --queryformat "%{NAME}-%{VERSION}-%{RELEASE}-%{ARCH}\n" | sort Greather-Sign-Symbol-Here /tmp/rpm-list
Product(s) Red Hat Enterprise LinuxComponent python subscription-manager yumCategory TroubleshootTags python yum
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.