2

This is a fresh install of Ubuntu 24.04. This has happened now on 2 separate servers. Both servers were up and running for a few days and had multiple successful apt update, apt upgrade sessions.

First server experienced the error yesterday during apt upgrade:

Preparing to unpack .../python3_3.12.3-0ubuntu2_amd64.deb ...
running python pre-rtupdate hooks for python3.12...
dpkg: error processing archive /var/cache/apt/archives/python3_3.12.3-0ubuntu2_amd64.deb (--unpack):
 new python3 package pre-installation script subprocess returned error exit status 3
Preparing to unpack .../libpython3-stdlib_3.12.3-0ubuntu2_amd64.deb ...
Unpacking libpython3-stdlib:amd64 (3.12.3-0ubuntu2) over (3.12.3-0ubuntu1) ...
Preparing to unpack .../libsmartcols1_2.39.3-9ubuntu6.1_amd64.deb ...
Unpacking libsmartcols1:amd64 (2.39.3-9ubuntu6.1) over (2.39.3-9ubuntu6) ...
Errors were encountered while processing:
 /var/cache/apt/archives/python3_3.12.3-0ubuntu2_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)***

If I try to run apt upgrade after the error I get this:

sudo apt upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 python3 : PreDepends: python3-minimal (= 3.12.3-0ubuntu1) but 3.12.3-0ubuntu2 is installed
           Depends: libpython3-stdlib (= 3.12.3-0ubuntu1) but 3.12.3-0ubuntu2 is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

I was unable to fix this and decided to re-install 24.04 from scratch.

Second server experienced the exact same crash this afternoon.

Anyone have any ideas on how to fix this and or prevent it from happening again?


sudo apt autoclean returns:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done

sudo apt clean gives no output

sudo apt update shows 23 packages to be updated

sudo apt -f install ends with an error:


Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  python3
Suggested packages:
  python3-doc python3-tk python3-venv
The following packages will be upgraded:
  python3
1 upgraded, 0 newly installed, 0 to remove and 22 not upgraded.
2 not fully installed or removed.
Need to get 23.0 kB of archives.
After this operation, 1,024 B disk space will be freed.
Do you want to continue? [Y/n] y
Get:1 http://us.archive.ubuntu.com/ubuntu noble-updates/main amd64 python3 amd64 3.12.3-0ubuntu2 [23.0 kB]
Fetched 23.0 kB in 0s (184 kB/s)   
(Reading database ... 218408 files and directories currently installed.)
Preparing to unpack .../python3_3.12.3-0ubuntu2_amd64.deb ...
running python pre-rtupdate hooks for python3.12...
dpkg: error processing archive /var/cache/apt/archives/python3_3.12.3-0ubuntu2_amd64.deb (--unpack):
 new python3 package pre-installation script subprocess returned error exit status 3
Errors were encountered while processing:
 /var/cache/apt/archives/python3_3.12.3-0ubuntu2_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

sudo apt install --reinstall python3-minimal libpython3-stdlib python3 ends with an error:


Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Suggested packages:
  python3-doc python3-tk python3-venv
The following packages will be upgraded:
  python3
1 upgraded, 0 newly installed, 2 reinstalled, 0 to remove and 22 not upgraded.
2 not fully installed or removed.
Need to get 27.4 kB/50.4 kB of archives.
After this operation, 1,024 B disk space will be freed.
Get:1 http://us.archive.ubuntu.com/ubuntu noble-updates/main amd64 python3-minimal amd64 3.12.3-0ubuntu2 [27.4 kB]
Fetched 27.4 kB in 1s (47.6 kB/s)          
E: Internal Error, No file name for libpython3-stdlib:amd64
Zanna
  • 72,312

1 Answers1

1

First, clean up:

sudo apt autoclean
sudo apt clean
sudo apt update
sudo apt -f install

Be sure to review the proposed changes before entering Y (make sure it doesn't want to uninstall stuff you want to keep).

If that doesn't automatically fix the issue, install the dependencies and then install python3:

sudo apt update
sudo apt install --reinstall python3-minimal libpython3-stdlib python3

EDIT: your error shows the correct pre-depends are already installed or not fully installed so run the following:

sudo dpkg --configure -a

and then:

sudo apt -f install

It is common to need to run dpkg --configure -a when apt -f install or --fix-broken install fails (or generally when apt fails). Often running these two commands over a few times in any particular order will resolve the issue.

If not, then:

sudo apt update
sudo apt install --reinstall libpython3-stdlib

if it still complains, then run:

cd /tmp
sudo apt download libpython3-stdlib
sudo dpkg --force-confmiss -i ./libpython3-stdlib*.deb
sudo dpkg --configure -a
cd

and now see if it still complains about python3-minimal when you try to upgrade python3:

sudo apt -o DPkg::Options::="--force-confmiss" --reinstall install python3

If it does complain about python3-minimal, then repeat the same process above as for libpython3-stdlib but with python3-minimal instead. Then run sudo apt install --reinstall python3.

If that works, upgrade the other 22 packages:

sudo apt update
sudo apt upgrade

You might want to check to see which mirror you're using in /etc/apt/sources.list if you're not using the default mirror, sometimes an alternative mirror might take longer to get all the packages available and this can cause issues similar to the one you've experienced.

Other than that, network issues and sometimes if you kill apt or dpkg during an update, you might experience the issue if one of the pre-depends packages isn't configured (needs sudo dpkg --configure -a).

You can actually check the installation status of a package by running:

dpkg -l | grep python

for example.

Fully installed packages should say ii in the first column (use dpkg -l | grep -v "^ii" to exclude fully installed packages). See this answer for other statuses (like rc means uninstalled but not purged so the configuration files are still in place).

mchid
  • 44,904
  • 8
  • 102
  • 162