When yum or dnf command execute, ImportError occurs

Solution Verified - Updated -

Issue

  • The following ImportError occurs when executing yum or dnf commands and fails:
# yum repolist
Traceback (most recent call last):
  File "/usr/lib64/python3.6/site-packages/libdnf/error.py", line 14, in swig_import_helper
    return importlib.import_module(mname)
  File "/usr/lib64/python3.6/importlib/init.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  ...
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: /lib64/libdnf.so.2: undefined symbol: sqlite3_db_readonly
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/bin/yum", line 57, in <module>
    from dnf.cli import main
  File "/usr/lib/python3.6/site-packages/dnf/init.py", line 30, in <module>
    import dnf.base
  ...
  File "/usr/lib64/python3.6/importlib/init.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_error' 

Environment

  • Red Hat Enterprise Linux 6, 7, 8

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content