23

I am trying to update Ubuntu and correct some system settings, however I am facing an issue I have been stuck on for over a week now.

When I type sudo apt-get install, I get:

The following packages have unmet dependencies.
 python3.9 : Depends: libpython3.9-stdlib (= 3.9.5-3~20.04.1) but 3.9.5-1+bionic1 is installed
 python3.9-minimal : Depends: libpython3.9-minimal (= 3.9.5-3~20.04.1) but 3.9.5-1+bionic1 is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

So I run sudo apt --fix-broken install and get:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  libpython3.9-minimal libpython3.9-stdlib
The following packages will be upgraded:
  libpython3.9-minimal libpython3.9-stdlib
2 to upgrade, 0 to newly install, 0 to remove and 33 not to upgrade.
2 not fully installed or removed.
Need to get 0 B/2,532 kB of archives.
After this operation, 483 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 200853 files and directories currently installed.)
Preparing to unpack .../libpython3.9-stdlib_3.9.5-3~20.04.1_amd64.deb ...
Unpacking libpython3.9-stdlib:amd64 (3.9.5-3~20.04.1) over (3.9.5-1+bionic1) ...
dpkg: error processing archive /var/cache/apt/archives/libpython3.9-stdlib_3.9.5-3~20.04.1_amd64.deb (--unpack):
 trying to overwrite '/usr/lib/python3.9/_sysconfigdata__linux_x86_64-linux-gnu.py', which is also in package libpython3.
9-minimal:amd64 3.9.5-1+bionic1
Preparing to unpack .../libpython3.9-minimal_3.9.5-3~20.04.1_amd64.deb ...
Unpacking libpython3.9-minimal:amd64 (3.9.5-3~20.04.1) over (3.9.5-1+bionic1) ...
dpkg: error processing archive /var/cache/apt/archives/libpython3.9-minimal_3.9.5-3~20.04.1_amd64.deb (--unpack):
 trying to overwrite '/usr/lib/python3.9/typing.py', which is also in package libpython3.9-stdlib:amd64 3.9.5-1+bionic1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/libpython3.9-stdlib_3.9.5-3~20.04.1_amd64.deb
 /var/cache/apt/archives/libpython3.9-minimal_3.9.5-3~20.04.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

I have tried a few things and searched for the errors in a few forums and I cant find a solution. It's really puzzling me.

I have even tried removing:

$ sudo apt remove libpython3.9-minimal/bionic libpython3.9-stdlib/bionic python3.9-minimal/focal-updates
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Selected version '3.9.5-1+bionic1' (New Python Versions:18.04/bionic [amd64]) for 'libpython3.9-minimal'
Selected version '3.9.5-1+bionic1' (New Python Versions:18.04/bionic [amd64]) for 'libpython3.9-stdlib'
Selected version '3.9.5-3~20.04.1' (Ubuntu:20.04/focal-updates, Ubuntu:20.04/focal-security [amd64]) for 'python3.9-minimal'
Selected version '3.9.5-3~20.04.1' (Ubuntu:20.04/focal-updates, Ubuntu:20.04/focal-security [amd64]) for 'libpython3.9-minimal' because of 'python3.9-minimal'
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies.
 python3.9 : Depends: python3.9-minimal (= 3.9.5-3~20.04.1) but it is not going to be installed
             Depends: libpython3.9-stdlib (= 3.9.5-3~20.04.1) but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

Any help would be great!

Added the followingg

$ apt-cache policy python3.9 libpython3.9-stdlib libpython3.9-minimal python3.9-minimal 

Installed: 3.9.5-3~20.04.1
  Candidate: 3.9.5-3~20.04.1
  Version table:
 *** 3.9.5-3~20.04.1 500
        500 ://gb.archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages
        500 ://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages
        100 /var/lib/dpkg/status
     3.9.5-1+focal1 500
        500 ://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main amd64 Packages
     3.9.5-1+bionic1 500
        500 ://ppa.launchpad.net/deadsnakes/ppa/ubuntu bionic/main amd64 Packages
libpython3.9-stdlib:
  Installed: 3.9.5-1+bionic1
  Candidate: 3.9.5-3~20.04.1
  Version table:
     3.9.5-3~20.04.1 500
        500 ://gb.archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages
        500 ://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages
     3.9.5-1+focal1 500
        500 ://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main amd64 Packages
 *** 3.9.5-1+bionic1 500
        500 ://ppa.launchpad.net/deadsnakes/ppa/ubuntu bionic/main amd64 Packages
        100 /var/lib/dpkg/status
libpython3.9-minimal:
  Installed: 3.9.5-1+bionic1
  Candidate: 3.9.5-3~20.04.1
  Version table:
     3.9.5-3~20.04.1 500
        500 ://gb.archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages
        500 ://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages
     3.9.5-1+focal1 500
        500 ://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main amd64 Packages
 *** 3.9.5-1+bionic1 500
        500 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu bionic/main amd64 Packages
        100 /var/lib/dpkg/status
libpython3.9-minimal:
  Installed: 3.9.5-1+bionic1
  Candidate: 3.9.5-3~20.04.1
  Version table:
     3.9.5-3~20.04.1 500
        500 ://gb.archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages
        500 ://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages
     3.9.5-1+focal1 500
        500 ://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main amd64 Packages
 *** 3.9.5-1+bionic1 500
        500 ://ppa.launchpad.net/deadsnakes/ppa/ubuntu bionic/main amd64 Packages
        100 /var/lib/dpkg/status
python3.9-minimal:
  Installed: 3.9.5-3~20.04.1
  Candidate: 3.9.5-3~20.04.1
  Version table:
 *** 3.9.5-3~20.04.1 500
        500 ://gb.archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages
        500 ://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages
        100 /var/lib/dpkg/status
     3.9.5-1+focal1 500
        500 ://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main amd64 Packages
     3.9.5-1+bionic1 500
        500 ://ppa.launchpad.net/deadsnakes/ppa/ubuntu bionic/main amd64 Packages

I ran

~/Downloads$ sudo ppa-purge ppa:deadsnakes/ppa # first for bionic

and this was a result

sudo ppa-purge ppa:deadsnakes/ppa # first for bionic
Updating packages lists
PPA to be removed: deadsnakes ppa
Package revert list generated:
 libpython3.8:amd64/focal libpython3.8-minimal:amd64/focal libpython3.8-stdlib:amd64/focal 
libpython3.9-minimal:amd64/focal libpython3.9-stdlib:amd64/focal python3.8/focal python3.8-minimal/focal

then the following:

understudy@understudy-System-Product-Name:~/Downloads$ sudo ppa-purge ppa:deadsnakes/ppa # second for focal
Updating packages lists
PPA to be removed: deadsnakes ppa
Warning:  Could not find package list for PPA: deadsnakes ppa
understudy@understudy-System-Product-Name:~/Downloads$ sudo ppa-purge ppa:deadsnakes/ppa # first for bionic
Updating packages lists
PPA to be removed: deadsnakes ppa
Warning:  Could not find package list for PPA: deadsnakes ppa

understudy@understudy-System-Product-Name:~/Downloads$ sudo apt-get install python3.9=3.9.5-3~20.04.1 libpython3.9-stdlib=3.9.5-3~20.04.1 \
> libpython3.9-minimal=3.9.5-3~20.04.1 python3.9-minimal=3.9.5-3~20.04.1 --reinstall
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libffi6 libncursesw5 libreadline7 libtinfo5
Use 'sudo apt autoremove' to remove them.
The following packages will be upgraded:
  libpython3.9-minimal libpython3.9-stdlib
2 to upgrade, 0 to newly install, 2 reinstalled, 0 to remove and 36 not to upgrade.
7 not fully installed or removed.
Need to get 0 B/2,532 kB of archives.
After this operation, 483 kB of additional disk space will be used.
E: Internal Error, No file name for python3.9-minimal:amd64

still seems to not like it

Disabling deadsnakes PPA from /etc/apt/sources.list.d/deadsnakes-ubuntu-ppa-focal.list
Disabling deadsnakes PPA from /etc/apt/sources.list.d/deadsnakes-ubuntu-ppa-bionic.list
Updating packages lists
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Selected version '3.8.5-1~20.04.3' (Ubuntu:20.04/focal-updates, Ubuntu:20.04/focal-security [amd64]) for 'libpython3.8'
Selected version '3.8.5-1~20.04.3' (Ubuntu:20.04/focal-updates, Ubuntu:20.04/focal-security [amd64]) for 'libpython3.8-minimal'
Selected version '3.8.5-1~20.04.3' (Ubuntu:20.04/focal-updates, Ubuntu:20.04/focal-security [amd64]) for 'libpython3.8-stdlib'
Selected version '3.9.5-3~20.04.1' (Ubuntu:20.04/focal-updates, Ubuntu:20.04/focal-security [amd64]) for 'libpython3.9-minimal'
Selected version '3.9.5-3~20.04.1' (Ubuntu:20.04/focal-updates, Ubuntu:20.04/focal-security [amd64]) for 'libpython3.9-stdlib'
Selected version '3.8.5-1~20.04.3' (Ubuntu:20.04/focal-updates, Ubuntu:20.04/focal-security [amd64]) for 'python3.8'
Selected version '3.8.5-1~20.04.3' (Ubuntu:20.04/focal-updates, Ubuntu:20.04/focal-security [amd64]) for 'python3.8-minimal'
The following packages were automatically installed and are no longer required:
  libffi6 libncursesw5 libreadline7 libtinfo5
Use 'sudo apt autoremove' to remove them.
Suggested packages:
  python3.8-venv python3.8-doc
The following packages will be upgraded:
  libpython3.9-minimal libpython3.9-stdlib
The following packages will be DOWNGRADED:
  libpython3.8 libpython3.8-minimal libpython3.8-stdlib python3.8 python3.8-minimal
2 to upgrade, 0 to newly install, 5 to downgrade, 0 to remove and 36 not to upgrade.
2 not fully installed or removed.
Need to get 6,280 kB/8,813 kB of archives.
After this operation, 1,083 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://gb.archive.ubuntu.com/ubuntu focal-updates/main amd64 libpython3.8 amd64 3.8.5-1~20.04.3 [1,624 kB]
Get:2 http://gb.archive.ubuntu.com/ubuntu focal-updates/main amd64 python3.8 amd64 3.8.5-1~20.04.3 [373 kB]
Get:3 http://gb.archive.ubuntu.com/ubuntu focal-updates/main amd64 libpython3.8-stdlib amd64 3.8.5-1~20.04.3 [1,671 kB]
Get:4 http://gb.archive.ubuntu.com/ubuntu focal-updates/main amd64 python3.8-minimal amd64 3.8.5-1~20.04.3 [1,897 kB]
Get:5 http://gb.archive.ubuntu.com/ubuntu focal-updates/main amd64 libpython3.8-minimal amd64 3.8.5-1~20.04.3 [715 kB]
Fetched 6,280 kB in 6s (969 kB/s)                                                                                      
(Reading database ... 200853 files and directories currently installed.)
Preparing to unpack .../0-libpython3.9-stdlib_3.9.5-3~20.04.1_amd64.deb ...
Unpacking libpython3.9-stdlib:amd64 (3.9.5-3~20.04.1) over (3.9.5-1+bionic1) ...
dpkg: error processing archive /tmp/apt-dpkg-install-vTH1pX/0-libpython3.9-stdlib_3.9.5-3~20.04.1_amd64.deb (--unpack):
 trying to overwrite '/usr/lib/python3.9/_sysconfigdata__linux_x86_64-linux-gnu.py', which is also in package libpython3.9-minimal:amd64 3.9.5-1+bionic1
Preparing to unpack .../1-libpython3.9-minimal_3.9.5-3~20.04.1_amd64.deb ...
Unpacking libpython3.9-minimal:amd64 (3.9.5-3~20.04.1) over (3.9.5-1+bionic1) ...
dpkg: error processing archive /tmp/apt-dpkg-install-vTH1pX/1-libpython3.9-minimal_3.9.5-3~20.04.1_amd64.deb (--unpack):
 trying to overwrite '/usr/lib/python3.9/typing.py', which is also in package libpython3.9-stdlib:amd64 3.9.5-1+bionic1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
dpkg: warning: downgrading libpython3.8:amd64 from 3.8.10-1+bionic1 to 3.8.5-1~20.04.3
Preparing to unpack .../2-libpython3.8_3.8.5-1~20.04.3_amd64.deb ...
Unpacking libpython3.8:amd64 (3.8.5-1~20.04.3) over (3.8.10-1+bionic1) ...
dpkg: warning: downgrading python3.8 from 3.8.10-1+bionic1 to 3.8.5-1~20.04.3
Preparing to unpack .../3-python3.8_3.8.5-1~20.04.3_amd64.deb ...
Unpacking python3.8 (3.8.5-1~20.04.3) over (3.8.10-1+bionic1) ...
dpkg: warning: downgrading libpython3.8-stdlib:amd64 from 3.8.10-1+bionic1 to 3.8.5-1~20.04.3
Preparing to unpack .../4-libpython3.8-stdlib_3.8.5-1~20.04.3_amd64.deb ...
Unpacking libpython3.8-stdlib:amd64 (3.8.5-1~20.04.3) over (3.8.10-1+bionic1) ...
dpkg: warning: downgrading python3.8-minimal from 3.8.10-1+bionic1 to 3.8.5-1~20.04.3
Preparing to unpack .../5-python3.8-minimal_3.8.5-1~20.04.3_amd64.deb ...
Unpacking python3.8-minimal (3.8.5-1~20.04.3) over (3.8.10-1+bionic1) ...
dpkg: warning: downgrading libpython3.8-minimal:amd64 from 3.8.10-1+bionic1 to 3.8.5-1~20.04.3
Preparing to unpack .../6-libpython3.8-minimal_3.8.5-1~20.04.3_amd64.deb ...
Unpacking libpython3.8-minimal:amd64 (3.8.5-1~20.04.3) over (3.8.10-1+bionic1) ...
Errors were encountered while processing:
 /tmp/apt-dpkg-install-vTH1pX/0-libpython3.9-stdlib_3.9.5-3~20.04.1_amd64.deb
 /tmp/apt-dpkg-install-vTH1pX/1-libpython3.9-minimal_3.9.5-3~20.04.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
/usr/local/bin/ppa-purge: line 191: aptitude: command not found
Warning:  Something went wrong, packages may not have been reverted

AFTER LATEST FIX ATTEMPT

understudy@understudy-System-Product-Name:~$ # sudo apt-get install ppa-purge
understudy@understudy-System-Product-Name:~$ cd ~/Downloads
understudy@understudy-System-Product-Name:~/Downloads$ sudo apt-get download ppa-purge
[sudo] password for understudy: 
understudy@understudy-System-Product-Name:~/Downloads$ dpkg -x ppa-purge_0.2.8+bzr63_all.deb ppap
understudy@understudy-System-Product-Name:~/Downloads$ sudo cp ppap/usr/sbin/ppa-purge /usr/local/bin/
understudy@understudy-System-Product-Name:~/Downloads$ sudo ppa-purge ppa:deadsnakes/ppa # first for bionic
Updating packages lists
PPA to be removed: deadsnakes ppa
Warning:  Could not find package list for PPA: deadsnakes ppa
understudy@understudy-System-Product-Name:~/Downloads$ sudo ppa-purge ppa:deadsnakes/ppa # second for focal
Updating packages lists
PPA to be removed: deadsnakes ppa
Warning:  Could not find package list for PPA: deadsnakes ppa

understudy@understudy-System-Product-Name:~/Downloads$ sudo apt-get install python3.9=3.9.5-3~20.04.1 libpython3.9-stdlib=3.9.5-3~20.04.1 \
> libpython3.9-minimal=3.9.5-3~20.04.1 python3.9-minimal=3.9.5-3~20.04.1 --reinstall
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libffi6 libncursesw5 libreadline7 libtinfo5
Use 'sudo apt autoremove' to remove them.
The following packages will be upgraded:
  libpython3.9-minimal libpython3.9-stdlib
2 to upgrade, 0 to newly install, 2 reinstalled, 0 to remove and 36 not to upgrade.
7 not fully installed or removed.
Need to get 0 B/2,532 kB of archives.
After this operation, 483 kB of additional disk space will be used.
E: Internal Error, No file name for python3.9-minimal:amd64
understudy@understudy-System-Product-Name:~/Downloads$ sudo apt-get install aptitude
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies.
 aptitude : Depends: aptitude-common (= 0.8.12-1ubuntu4) but it is not going to be installed
            Depends: libcwidget4 (>= 0.5.18-1) but it is not going to be installed
            Recommends: libparse-debianchangelog-perl but it is not going to be installed
 python3.9 : Depends: libpython3.9-stdlib (= 3.9.5-3~20.04.1) but 3.9.5-1+bionic1 is to be installed
 python3.9-minimal : Depends: libpython3.9-minimal (= 3.9.5-3~20.04.1) but 3.9.5-1+bionic1 is to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

after the sudo apt --fix-broken install

[sudo] password for understudy: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  libffi6 libncursesw5 libreadline7 libtinfo5
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  libpython3.9-minimal libpython3.9-stdlib
The following packages will be upgraded:
  libpython3.9-minimal libpython3.9-stdlib
2 to upgrade, 0 to newly install, 0 to remove and 36 not to upgrade.
7 not fully installed or removed.
Need to get 0 B/2,532 kB of archives.
After this operation, 483 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 200857 files and directories currently installed.)
Preparing to unpack .../libpython3.9-stdlib_3.9.5-3~20.04.1_amd64.deb ...
Unpacking libpython3.9-stdlib:amd64 (3.9.5-3~20.04.1) over (3.9.5-1+bionic1) ...
dpkg: error processing archive /var/cache/apt/archives/libpython3.9-stdlib_3.9.5-3~20.04.1_amd64.deb (--unpack):
 trying to overwrite '/usr/lib/python3.9/_sysconfigdata__linux_x86_64-linux-gnu.py', which is also in package libpython3.9-minimal:amd64 3.9.5-1+bionic1
Preparing to unpack .../libpython3.9-minimal_3.9.5-3~20.04.1_amd64.deb ...
Unpacking libpython3.9-minimal:amd64 (3.9.5-3~20.04.1) over (3.9.5-1+bionic1) ...
dpkg: error processing archive /var/cache/apt/archives/libpython3.9-minimal_3.9.5-3~20.04.1_amd64.deb (--unpack):
 trying to overwrite '/usr/lib/python3.9/typing.py', which is also in package libpython3.9-stdlib:amd64 3.9.5-1+bionic1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/libpython3.9-stdlib_3.9.5-3~20.04.1_amd64.deb
 /var/cache/apt/archives/libpython3.9-minimal_3.9.5-3~20.04.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
7
  • 1
    What is your Ubuntu version? Why do you mix 18.04 (bionic) with 20.04 (focal) repos? Please also add output of apt-cache policy python3.9 libpython3.9-stdlib libpython3.9-minimal python3.9-minimal to the question.
    – N0rbert
    Jun 1, 2021 at 8:07
  • HI I put the output in the original post due to the size Jun 1, 2021 at 8:24
  • Distributor ID: Ubuntu Description: Ubuntu 20.04.2 LTS Release: 20.04 Codename: focal Jun 1, 2021 at 8:24
  • Why do you mix 18.04 (bionic) with 20.04 (focal) repos? - I am not sure why this has happened Jun 1, 2021 at 8:25
  • Install Aptitude with sudo apt-get install aptitude .
    – N0rbert
    Jun 1, 2021 at 14:24

8 Answers 8

37

This worked for me. I found the packages that errored out and installed them using dpkg:

sudo dpkg -i --force-all /var/cache/apt/archives/libpython3.9-stdlib_3.9.12-1+bionic2_amd64.deb
sudo dpkg -i --force-all /var/cache/apt/archives/libpython3.9-minimal_3.9.12-1+bionic2_amd64.deb

Note: You may have a different version of these packages which can be found using ls /var/cache/apt/archives/ | grep libpython3.9-

Then I could update:

sudo apt-get update -y && sudo apt-get install --fix-broken
2
  • 1
    In my case it says minimal is dependency of stdlib so I had to install minimal first. But those are the files. Thx.
    – WesternGun
    Jun 8, 2022 at 14:20
  • Amazing, this helped me after 3 months of this same error! Thank you so much!!!
    – rom
    Jul 18, 2022 at 6:38
9

You have unnecessary PPA repository added. To remove it use commands below:

# sudo apt-get install ppa-purge
cd ~/Downloads
apt-get download ppa-purge
dpkg -x ppa-purge_0.2.8+bzr63_all.deb ppap
sudo cp ppap/usr/sbin/ppa-purge /usr/local/bin/

sudo ppa-purge ppa:deadsnakes/ppa # first for bionic
sudo ppa-purge ppa:deadsnakes/ppa # second for focal

and then reinstall normal python versions from official 20.04 LTS repositories:

sudo apt-get install python3.9=3.9.5-3~20.04.1 libpython3.9-stdlib=3.9.5-3~20.04.1 \
libpython3.9-minimal=3.9.5-3~20.04.1 python3.9-minimal=3.9.5-3~20.04.1 --reinstall

Then install Aptitude with

sudo apt-get install aptitude

and resume package installation by

sudo add-apt-repository main
sudo add-apt-repository universe
sudo add-apt-repository multiverse
sudo add-apt-repository restricted

sudo apt-get update
sudo apt-get install -f
sudo dpkg -i --force-all /var/cache/apt/archives/libpython3.9-stdlib_3.9.5-3~20.04.1_amd64.deb /var/cache/apt/archives/libpython3.9-minimal_3.9.5-3~20.04.1_amd64.deb

sudo dpkg --configure -a
sudo aptitude install python3.9=3.9.5-3~20.04.1 libpython3.9-stdlib=3.9.5-3~20.04.1 \
libpython3.9-minimal=3.9.5-3~20.04.1 python3.9-minimal=3.9.5-3~20.04.1
sudo aptitude dist-upgrade
2
  • N0rbert thank you so much - that seems to of worked!! i really appreciate it, i have beeb suck for ages :-) Jun 2, 2021 at 14:03
  • I'm glad, that it is now fixed. So you can mark this problem as solved by clicking checkmark in the left of my answer.
    – N0rbert
    Jun 2, 2021 at 14:06
6

This article helped me dpkg error code 1

sudo dpkg --configure -a
sudo apt remove --purge python3.9-minimal python3.9
sudo apt autoremove
sudo apt upgrade
1
  • Isn't faster to just sudo apt autoremove --purge python3.9-minimal python3.9 ?
    – Igor Foxly
    Jun 20, 2021 at 6:43
3

Diagnosing:

See what sudo apt upgrade says:

myself@box:~$ sudo apt upgrade
[sudo] password for myself: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies.
 python3.9 : Depends: libpython3.9-stdlib (= 3.9.5-3~20.04.1) but 3.9.5-1+bionic1 is installed
 python3.9-minimal : Depends: libpython3.9-minimal (= 3.9.5-3~20.04.1) but 3.9.5-1+bionic1 is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

Conclusion: something is wrong with some Python 3.9 packages.


Overview:

List all the Python 3.9 packages. Good to compare this listing before and after you implement the solution.

# Command:
sudo dpkg -l | grep 'python3\.9' | awk '{print $2}'

# Output:
libpython3.9-minimal:amd64
libpython3.9-stdlib:amd64
python3.9
python3.9-distutils
python3.9-lib2to3
python3.9-minimal
python3.9-venv

Solution:

No need to remove/purge the deadsnakes ppa.

  1. Issue this command to delete all Python 3.9 packages:

     myself@box:~$ sudo apt --fix-missing purge $(dpkg -l | grep 'python3\.9' | awk '{print $2}')
    
  2. Answer Y to execute the removal of the listed packages.

  3. Install the same packages again:

    • Alternative A) SLOWER AND SMARTER VERSION: Install only the packages you know you want to install, they will be set by apt as manually installed:

       myself@box:~$ sudo apt install python3.9 python3.9-venv
      

      and see if the other packages are installed automatically as dependencies. If not, install the other missing packages manually, too.

    • Alternative B) FASTER AND DUMBER VERSION: Copy the package names from the list created by apt --fix-missing purge, remove the stars and install them (again):

      myself@box:~$ sudo apt install libpython3.9-minimal libpython3.9-stdlib python3.9 python3.9-minimal python3.9-venv
      
  4. Voluntary: check with the Overview-command from above that you have the same packages installed now, as before implementing the solution.


Source and explanation of each part of the command (#1) are found here https://askubuntu.com/a/1402567

1

I had this same problem after trying to install software that required an older version of Python from the Deadsnakes PPA. It was pretty scary because even synaptic led me to believe that there was no route to downgrading Python3.9 without affecting important system packages in a way that probably would have been unrecoverable.

This command worked for me. Obviously replace the package version (check with sudo synaptic or apt-cache policy python3.9) below with your desired system version of Python after purging the deadsnakes PPA:

sudo ppa-purge ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install -yf --allow-downgrades libpython3.9-dev=3.9.7-2build1 python3.9-minimal=3.9.7-2build1 libpython3.9-minimal=3.9.7-2build1 python3.9-dev=3.9.7-2build1
1
  • You fixed it for me! Thank you stranger from 2022.
    – NPike
    May 19, 2023 at 5:27
0

There is a thread on https://github.com/deadsnakes/issues/issues/148, which seems to explain the problem mentioned in the question here and which suggests to simply force the installation:

sudo apt install -yf

This worked for me (using python 3.9.10 on Ubuntu 20.04).

0

I had the same problem and could solved with this

sudo dpkg -i --force-all /var/cache/apt/archives/libpython3.9-stdlib_3.9.5-3ubuntu0~20.04.1_amd64.deb /var/cache/apt/archives/libpython3.9-minimal_3.9.5-3ubuntu0~20.04.1_amd64.deb

0

I had same but slightly different(??) issue:

error:

jetsonagx@jetsonagx-desktop:~/Downloads/nvidia/sdkm_downloads$ sudo apt-get install python3.9
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    You might want to run 'apt --fix-broken install' to correct these.
    The following packages have unmet dependencies:
     python3.9 : Depends: python3.9-minimal (= 3.9.5-3ubuntu0~20.04.1) but it is not going to be installed
             Depends: libpython3.9-stdlib (= 3.9.5-3ubuntu0~20.04.1) but it is not going to be installed             
    E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

Note! not, there is no +bionic1 is installed text in displayed error


I solved it by manually downloading and installing .deb files:

# download required files
$ wget http://ports.ubuntu.com/pool/universe/p/python3.9/python3.9-minimal_3.9.5-3ubuntu0~20.04.1_arm64.deb     # python3.9-minimal
$ wget http://ports.ubuntu.com/pool/universe/p/python3.9/libpython3.9-minimal_3.9.5-3ubuntu0~20.04.1_arm64.deb  # libpython3.9-minimal (python3.9-minimal required it)
$ wget http://ports.ubuntu.com/pool/universe/p/python3.9/libpython3.9-stdlib_3.9.5-3ubuntu0~20.04.1_arm64.deb   # python3.9-sdlib

# install downloaded files
$ sudo dpkg -i libpython3.9-minimal_3.9.5-3ubuntu0~20.04.1_arm64.deb    
$ sudo dpkg -i libpython3.9-stdlib_3.9.5-3ubuntu0~20.04.1_arm64.deb
$ sudo apt-get install python3.9

I hope it will be helpful for someone)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .