54

apt upgrade:

$ sudo apt-get full-upgrade -y

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:
 libpython3.10 : Depends: libpython3.10-stdlib (= 3.10.4-1+focal2) but 3.10.4-1+focal1 is installed
 libpython3.10-dev : Depends: libpython3.10-stdlib (= 3.10.4-1+focal2) but 3.10.4-1+focal1 is installed
 python3.10 : Depends: libpython3.10-stdlib (= 3.10.4-1+focal2) but 3.10.4-1+focal1 is installed
 python3.10-minimal : Depends: libpython3.10-minimal (= 3.10.4-1+focal2) but 3.10.4-1+focal1 is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

apt --fix-broken install:

$ sudo apt --fix-broken install

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

Tried to remove installed python3.10 packages but it results in error Unmet dependencies

What does this error message means and is there's a way to fix it?

muru
  • 193,181
  • 53
  • 473
  • 722
Udesh
  • 783
  • 1
  • 6
  • 11
  • 2
    You should report this bug to whoever provided you with the python packages that you're using. This sounds like a packaging bug and whoever made those packages should know about it. – sarnold Apr 18 '22 at 20:18

3 Answers3

102

Try removing the problematic packages ie libpython3.10-minimal libpython3.10-stdlib.

sudo apt remove libpython3.10-minimal libpython3.10-stdlib

If this says to run --fix-broken then remove it manually ie like this

ls -l /var/lib/dpkg/info | grep -i libpython3.10-minimal

This shows the truncated file names which contain libpython3.10-minimal. Now move it into a different directory

sudo mv /var/lib/dpkg/info/libpython3.10-minimal:amd64.* /tmp

Then do

sudo apt --fix-broken install

It will say that libpython3.10-minimal not found so it will reinstall it.

Rice
  • 1,160
  • 1
  • 6
  • 13
  • what was the issue can you please elaborate it ? why did this problem arised and why after removing `/var/lib/dpkg/info/libpython3.10-minimal:amd64.*` fixed the problem ? – Udesh Apr 14 '22 at 04:41
  • 10
    @UdeshRanjan one file moved from -stdlib to -minimal, another file moved from -minimal to -stdlib, so neither one could go first without overwriting a file from the other. Removing them both cleared that condition (though I would have used `dpkg --remove --force-all` rather than faking up /var/lib/dpkg/info) – hobbs Apr 14 '22 at 17:31
  • In my case I had to do: sudo apt install libpython3.10-minimal at the end as the sudo apt --fix-broken install command didn't try to reinstall the packages – mcarans Apr 14 '22 at 22:23
  • 3
    I followed @hobbs advice and solved the problem very easily in Ubuntu 20.04 LTS: `sudo dpkg --remove --force-all libpython3.10-minimal libpython3.10-stdlib` followed by `sudo apt install libpython3.10-minimal libpython3.10-stdlib`. – apocalipisis Apr 19 '22 at 08:50
  • I guess in my case the issue happened because I compiled python3.10 from source. Now it is fixed with this answer. – Emil Jun 10 '22 at 18:31
  • Lifesaver. Spend last 3 hours trying to fully delete deadsnakes ppa with the faulty packages, broken the install twice, while doing it, and all I needed is to use these two simple commands – Igor Tiulkanov Nov 11 '22 at 14:57
15

As Rice and hobbs said, the problem is that a file moved from one package to another, and they are now stepping on each other during the update. I followed their advice to force the upgrade, but had to tweak it a bit. Here's what I ended up doing:

sudo dpkg --force-all --remove libpython3.10-stdlib libpython3.10-minimal

That forces the two colliding packages to uninstall, even though others depend on them.

sudo apt-get install libpython3.10-stdlib libpython3.10-minimal

That installs them again, without stepping on each other. sudo apt --fix-broken install might also work at this point, but I didn't try it.

Don Kirkby
  • 1,437
  • 14
  • 22
1

Answer adjusted from here

No need to remove them, forcefully install one package, than fix the rest.

sudo dpkg -i --force-overwrite /var/cache/apt/archives/libpython3.10-stdlib_3.10.4-1+focal2_amd64.deb
sudo apt --fix-broken install
Ohad Cohen
  • 765
  • 5
  • 16