3

I use redis in my project. However, when I try to start the server with the following command, '$ redis-server --daemonize yes', I keep getting the same error message that says no module named 'apt_pkg'. Please assist me with this issue!

Traceback (most recent call last):
  File "/usr/lib/command-not-found", line 28, in <module>
    from CommandNotFound import CommandNotFound
  File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 19, in <module>
    from CommandNotFound.db.db import SqliteDatabase
  File "/usr/lib/python3/dist-packages/CommandNotFound/db/db.py", line 5, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
Khashhogi
  • 41
  • 1
  • 3

1 Answers1

1

I had the same issue. I resolved it.

There is a python script called command-not-found in /usr/lib/command-not-found.

This script, gets updated after you upgrade your python version. At least that's what happened to me. I upgraded from Python3.6 to Python3.8. Then I saw this problem.

Now, the issue is, This script is working based on the previous version of Python. So I went into this file, and changed the first line from:

#!/usr/bin/python3 (which refers to python3.8)

to:

#!/usr/bin/python3.6 (which is python version comes with Ubuntu 18.04)

flowfelis
  • 11
  • 2