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.
/usr/bin/python3
to whatever the default version is. You could re-create it manually with something likesudo ln -s /usr/bin/python3.8 /usr/bin/python3
to get you out of this hole. – popey Mar 02 '23 at 09:02python3.8
... Link it back topython3
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 Mar 02 '23 at 10:01