PopOS apt-get update broken

My apt-get update is broken after installing python3, pop os 20.04 LTS.

I must have installed python3 incorrectly or changed some of the settings for default application use with python versions.
I’m not a linux master and would prefer to not have to reinstall popos.

Here are the errors.

Hit:1 http://apt.pop-os.org/proprietary focal InRelease
Hit:2 http://us.archive.ubuntu.com/ubuntu focal InRelease           
Hit:3 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal InRelease
Hit:4 http://repository.spotify.com stable InRelease
Hit:5 http://us.archive.ubuntu.com/ubuntu focal-security InRelease       
Hit:6 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease              
Hit:7 http://ppa.launchpad.net/system76/pop/ubuntu focal InRelease
Hit:8 http://us.archive.ubuntu.com/ubuntu focal-backports InRelease
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
sudo dpkg --purge --force-all  python
sudo apt install -f

This basically will remove everything, including the config files for the package. Try it and tell me what happens.

Preparing to unpack .../libglib2.0-dev-bin_2.64.3-1~ubuntu20.04.1_amd64.deb ...
/var/lib/dpkg/info/libglib2.0-dev-bin.prerm: 6: py3clean: not found
dpkg: warning: old libglib2.0-dev-bin package pre-removal script subprocess retu
rned error exit status 127
dpkg: trying script from the new package instead ...
/var/lib/dpkg/tmp.ci/prerm: 6: py3clean: not found
dpkg: error processing archive /var/cache/apt/archives/libglib2.0-dev-bin_2.64.3
-1~ubuntu20.04.1_amd64.deb (--unpack):
 new libglib2.0-dev-bin package pre-removal script subprocess returned error exi
t status 127
/var/lib/dpkg/info/libglib2.0-dev-bin.postinst: 6: py3compile: not found
dpkg: error while cleaning up:
 installed libglib2.0-dev-bin package post-installation script subprocess return
ed error exit status 127
Preparing to unpack .../libglib2.0-dev_2.64.3-1~ubuntu20.04.1_amd64.deb ...
Unpacking libglib2.0-dev:amd64 (2.64.3-1~ubuntu20.04.1) over (2.64.2-1~fakesync1
) ...
Errors were encountered while processing:
 /var/cache/apt/archives/libglib2.0-dev-bin_2.64.3-1~ubuntu20.04.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

how did you install python3 to begin with?

IIRC Pop just a single button click to get it done.

(It was done a few weeks ago, I went away on holiday).

I’m pretty sure I had a problem with python3 when I installed it, I couldn’t load gnome programs, so I tried to remove it and was having other problems…
Then I just removed all python versions and installed python manually, I guess that was a mistake.

I currently have in my /usr/local/bin

python2
python2.7
python3
python3.7
python3.7m

What versions does popos have installed by default, and how should I go about removing and reinstalling?

I’m not sure if I need to change any other configs to make sure the programs use the correct version too.

Python3 is installed by default on the latest versions of PopOS (IIRC). Furthermore, python3 is used by the system for various programs so one cannot cleanly remove all python versions.

If you need to work with multiple python versions it is reccomended to leave the system version alone and simply use pip to create a virtualenv with the python version you need so as to not bork your system.

Since you have a lot of different python versions installed you will probably have to fix what the system expects /usr/bin/python -> /path/to/correct/python_version.

I am unsure how you installed it though and without that information I cannot really help you undo what you did previously.

2 Likes

I installed python2.7 by following the guide on their website, make make install etc

Link to the guide please? The one on Python’s website?

There should be no need to use make and compile it yourself. It should be available via the repos, or via pip like how I mentioned above.

Since you installed python2.7 its likely this changed your symlink of what python points to so everything that expects /usr/bin/python to be python3 is now getting python2 and malfunctioning.

ls -hal /usr/bin/python*
# and
ls -hal /usr/local/bin/python*

as i said it was a few weeks ago and I cant find the exact guide I followed. But i just wget the 2.7 into the /usr/local/bin directory and installed from there.

ls -hal /usr/bin/python*
lrwxrwxrwx 1 root root 33 Apr 27 23:53 /usr/bin/python3.8-config -> x86_64-linux-gnu-python3.8-config
lrwxrwxrwx 1 root root 16 Mar 13 20:20 /usr/bin/python3-config -> python3.8-config
tyson@pop-os:/usr/local/bin$ ls -hal /usr/local/bin/python*
lrwxrwxrwx 1 root root    7 Jul  6 18:47 /usr/local/bin/python -> python2
lrwxrwxrwx 1 root root    9 Jul  6 18:47 /usr/local/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 9.4M Jul  6 18:47 /usr/local/bin/python2.7
-rwxr-xr-x 1 root root 1.7K Jul  6 18:47 /usr/local/bin/python2.7-config
lrwxrwxrwx 1 root root   16 Jul  6 18:47 /usr/local/bin/python2-config -> python2.7-config
lrwxrwxrwx 1 root root    9 Jul  6 19:09 /usr/local/bin/python3 -> python3.7
-rwxr-xr-x 2 root root  16M Jul  6 19:09 /usr/local/bin/python3.7
lrwxrwxrwx 1 root root   17 Jul  6 19:09 /usr/local/bin/python3.7-config -> python3.7m-config
-rwxr-xr-x 2 root root  16M Jul  6 19:09 /usr/local/bin/python3.7m
-rwxr-xr-x 1 root root 2.9K Jul  6 19:09 /usr/local/bin/python3.7m-config
lrwxrwxrwx 1 root root   16 Jul  6 19:09 /usr/local/bin/python3-config -> python3.7-config
lrwxrwxrwx 1 root root   14 Jul  6 18:47 /usr/local/bin/python-config -> python2-config

Thank you this helps a bunch.

So as I suspected, the default version of python that your system sees when calling python is 2.7 and if they want to use python 3.7 they need to use python3.

I am not sure what it was previously though on a fresh system.

But that doesn’t look too out of the ordinary.

What I would suggest next it to uninstall the offending package and clean the metadata.

NVM I see you did that already.

So my cnf-update-db isn’t even working.

Just says /usr/bin/python bad interpreter no such file or directory

I dont think its a python issue because I tired my other python version 2 and it gets the same problem.

But I never edited cnf-update-db so i can’t see that being the issue.

If it helps my Pop 20.04 install looks like:

ls -hal /usr/bin/python*
lrwxrwxrwx 1 root root    9 Mar 13 05:31 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 3.6M Apr  7 05:05 /usr/bin/python2.7
lrwxrwxrwx 1 root root    9 Mar 13 05:20 /usr/bin/python3 -> python3.8
-rwxr-xr-x 1 root root 5.3M Apr 27 08:53 /usr/bin/python3.8
-rwxr-xr-x 1 root root  384 Mar 27 19:39 /usr/bin/python3-futurize
-rwxr-xr-x 1 root root  388 Mar 27 19:39 /usr/bin/python3-pasteurize

I have not done anything with python unless it was a dependency for a program.

Edit: and /usr/local/bin doesn’t have anything python in it.

There’s no /usr/bin/python3, that’ll break any script with that on line 1; if the shebang specifies the full path, no lookup via the PATH will happen and /usr/local/bin/python3 won’t be found. Maybe you could try linking to that:

sudo ln -s /usr/local/bin/python3 /usr/bin/python3
1 Like