0

When I run sudo apt update I get the following error:

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 believe the problem might be connected to Python. After running sudo apt-get install -f, the following messages appear:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 to upgrade, 0 to newly install, 0 to remove and 19 not to upgrade.
3 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up python3-wheel (0.30.0-0.2) ...
/var/lib/dpkg/info/python3-wheel.postinst: 6: /var/lib/dpkg/info/python3-wheel.postinst: py3compile: not found
dpkg: error processing package python3-wheel (--configure):
 installed python3-wheel package post-installation script subprocess returned error exit status 127
Setting up python3-pip (9.0.1-2.3~ubuntu1.18.04.1) ...
/var/lib/dpkg/info/python3-pip.postinst: 6: /var/lib/dpkg/info/python3-pip.postinst: py3compile: not found
dpkg: error processing package python3-pip (--configure):
 installed python3-pip package post-installation script subprocess returned error exit status 127
Setting up python3-setuptools (39.0.1-2) ...
/var/lib/dpkg/info/python3-setuptools.postinst: 6: /var/lib/dpkg/info/python3-setuptools.postinst: py3compile: not found
dpkg: error processing package python3-setuptools (--configure):
 installed python3-setuptools package post-installation script subprocess returned error exit status 127
Errors were encountered while processing:
 python3-wheel
 python3-pip
 python3-setuptools
E: Sub-process /usr/bin/dpkg returned an error code (1)

As I'm quite new to Linux, can anyone help me out with fixing this problem?

After running sudo apt install --reinstall python3-minimal the problem seems to have disappeared and everything seems to be working fine now (even Terminal is back). In any case, here is the result of python -v: Python 2.7.15+

1 Answers1

0

This exact question with the same error was asked a year ago. The solution is to create a symlink to python to fix the issue:

So check where the link /usr/bin/python is pointing to:

$ ls -la /usr/bin/python
lrwxrwxrwx 1 root root 9 Jan 24  2017 /usr/bin/python -> python2.7
It should point to python2, not to any python3 executable. If it points to python3 then do the following (man ln):

$ sudo rm -f /usr/bin/python
$ sudo ln -s /usr/bin/python2.7 /usr/bin/python

After that, the apt-get/apt will start to work again.

Error when trying sudo apt-get update - Python related? Error in the post shows:

sh 1: /usr/lib/cnf-update-db: not found
Reading package lists... Done
E: Problem executing scripts APT::Update::Post-Invoke-Succes 'if /usr/bin/test -w /var/lib/command-not-found -a -e /usr/lib/cnf-update-db > /dev/null; fi'
E: Sub-process returned an error code
SimpliFixed
  • 179
  • 7