Score:0

Why I got error after Python upgrade? /usr/lib/cnf-update-db: not found

ug flag

I tried everything,I still have the error

sudo apt update

shows

sh: 1: /usr/lib/cnf-update-db: not found
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 tried back and fort Pyhton2,3. Now

python --version
Python 2.7.18

python3 --version
bash: /usr/lib/command-not-found: /usr/bin/python3: bad interpreter: No such file or directory

ls -l /usr/bin/python*
lrwxrwxrwx 1 root root      18 Mar  2 09:37 /usr/bin/python -> /usr/bin/python2.7
lrwxrwxrwx 1 root root       9 Mar 13  2020 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 3662032 Jul  1  2022 /usr/bin/python2.7
-rwxr-xr-x 1 root root 5494584 Nov 14 13:59 /usr/bin/python3.8
lrwxrwxrwx 1 root root      33 Nov 14 13:59 /usr/bin/python3.8-config -> x86_64-linux-gnu-python3.8-config
-rwxr-xr-x 1 root root 5762192 Dec  7 02:11 /usr/bin/python3.9
lrwxrwxrwx 1 root root      16 Mar 13  2020 /usr/bin/python3-config -> python3.8-config
-rwxr-xr-x 1 root root     384 Jan 25 09:33 /usr/bin/python3-futurize
-rwxr-xr-x 1 root root     388 Jan 25 09:33 /usr/bin/python3-pasteurize
-rwxr-xr-x 1 root root    5902 Jan 13  2020 /usr/bin/python3-wsdump
-rwxr-xr-x 1 root root    2555 Apr 14  2020 /usr/bin/python-argcomplete-check-easy-install-script3
-rwxr-xr-x 1 root root     314 Apr 14  2020 /usr/bin/python-argcomplete-tcsh3

This error when trying sudo relates to 2018 year. After

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1

which python3

shows

/usr/bin/python3

which python3.9
/usr/bin/python3.9

One other consequence is that I can not open Terminal(Terminator) form Gnome.

how to fix this? Problems persist again.

pl flag
What version of Ubuntu are you running? How did you "upgrade" python? Upgrading the default python version often breaks things.
Richard Rublev avatar
ug flag
@popey 20.04 Ubuntu,I just install python3.9 with pip3 install. I need that for Ansible.
pl flag
There's usually a symlink from `/usr/bin/python3` to whatever the default version is. You could re-create it manually with something like `sudo ln -s /usr/bin/python3.8 /usr/bin/python3` to get you out of this hole.
Raffa avatar
jp flag
The default python for your system is `python3.8` ... Link it back to `python3` as shown in @popey's comment above ... And don't ever alter the default system python version or else that will happen again and it's not always fixable ... So if you managed to fix it with the command above, consider it a lesson learned ... Ubuntu relies on the default system python version ... It's an essential part of the OS and not just an interpreter to run your python scripts.
Raffa avatar
jp flag
Related and might help: https://askubuntu.com/q/1448702
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.