0

I don't know what's wrong with my packages or ppas but every time I try to run sudo apt update in my zsh terminal, it logs this error:

Fetched 222 kB in 1s (155 kB/s)                  
Traceback (most recent call last):
  File "/usr/lib/cnf-update-db", line 26, in <module>
    col.create(db)
  File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 108, in create
    os.rename(tmpdb, dbname)
IsADirectoryError: [Errno 21] Is a directory: '/var/lib/command-not-found/commands.db.tmp' -> '/var/lib/command-not-found/commands.db'
Reading package lists... Done
E: Problem executing scripts APT::Update::Post-Invoke-Success 'if /usr/bin/test -w /var/lib/command-not-found/ -a -e /usr/lib/cnf-update-db; then /usr/lib/cnf-update-db > /dev/null; fi'
E: Sub-process returned an error code

I just know it's a python error but I don't know what it means. Os is kubuntu 20.04, and python3 version is 3.9.9

Aprime
  • 121
  • 1
  • 10
  • 1
    We don't know your OS & release details; but I'd use that knowledge & check the results of `python3 --version` are correct for your *unstated* release; as python3 errors are commonly the result of incorrect python3 version changes. – guiverc Dec 27 '21 at 08:10
  • Os is kubuntu 20.04, and python3 version is 3.9.9. – Aprime Dec 27 '21 at 08:12
  • 2
    and there is your issue; you've changed your default python3 to a result that doesn't belong in 20.04; reverse your python3 changes & do it properly. – guiverc Dec 27 '21 at 08:14
  • Dude I need 3.9.9 python:) What's the proper issue? Can you suggest a link or something? – Aprime Dec 27 '21 at 08:16
  • Many Ubuntu tools are designed to work with the `python3` the machine comes with; so you'll have to leave the default python3 be what the machine comes with (`python3` defaults to 3.9.9 for my newer release) and use a second/newer python3 for your scripts that rely on it; OR don't use Ubuntu tools that rely on python3 being the default (eg. live with `apt` & like tools that are designed/tested to work only with the default python3). As I said do it properly (and don't change the default!) Your question/problem here is because you changed the python3 version incorrectly. – guiverc Dec 27 '21 at 08:48
  • 2
    Does this answer your question? [Ubuntu 16.04 Completely broken python3 + dpkg + apt-get!](https://askubuntu.com/questions/1092919/ubuntu-16-04-completely-broken-python3-dpkg-apt-get) – guiverc Dec 27 '21 at 08:49
  • Does this answer your question? [Problem with sudo apt update in Ubuntu 18.04: Post-Invoke-Success if /usr/bin/test -w /var/lib/command-not-found/](https://askubuntu.com/questions/1041226/problem-with-sudo-apt-update-in-ubuntu-18-04-post-invoke-success-if-usr-bin-te) – karel Dec 28 '21 at 01:52

0 Answers0