0

I am getting an error for upgrading Ubuntu packages, it suggested running apt --fix-broken install but doing that didn't do it. I searched and the only answer I found was removing the packages which I am reluctant to do, cause I might mess it up.

I installed python3.10 some months ago, and my projects depend on it.

  • sudo apt-get upgrade
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).
  • Running sudo apt --fix-broken install
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-minima
l:amd64 3.10.4-1+focal1
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)
OMY
  • 103
  • Hello. How did your Ubuntu 20.04 get python 3.10? It has a default of python 3.8 – David Apr 14 '22 at 13:36
  • @David Hi, I installed it for a project. – OMY Apr 14 '22 at 13:37
  • Did you remove the 3.8? Hope not it breaks the machine. Did you add a PPA for the 3.10? – David Apr 14 '22 at 13:42
  • @David No, I didn't remove 3.8, it still is there. Yes, I used deadsnakes' ppa. – OMY Apr 14 '22 at 13:44
  • 1
    OK. Remove the PPA from the sources list and that should stop it from trying to update 3.10 BTW It would have been a better idea to have used a VM for this project. – David Apr 14 '22 at 13:46
  • @david Thanks, fixed it. But I cannot update my python? Can I add deadsnake? will it happen again? – OMY Apr 14 '22 at 13:51
  • 1
    When there is a PPA active it will always try and update the software the PPA references. Ubuntu 20.04 uses 3.8 so I do not think you can update the usual way with it. I do not know if it can be done a manual way. – David Apr 14 '22 at 13:57
  • I made this an answer. – David Apr 14 '22 at 13:59
  • 1
    Since the answer works can you accept please? – David Apr 14 '22 at 14:08

2 Answers2

5

Check out this solution. https://github.com/deadsnakes/issues/issues/207 Specifically https://github.com/deadsnakes/issues/issues/207#issuecomment-1098684655 helped me

sudo apt purge libpython3.10-minimal libpython3.10-stdlib libpython3.10 libpython3.10-dev python3.10 python3.10-minimal python3.10-dev python3.10-venv
sudo apt install python3.10
honzaik
  • 166
  • This worked for me: sudo apt remove $(apt list --installed | egrep 'python.3.10' | sed 's|/.$||'); sudo apt install python3.10 python3.10-venv – Peter Ludemann Apr 15 '22 at 23:24
1

If you do not want or can not have the software from a PPA trying to update you can remove it from the sources list and it will not try and update that software.

David
  • 2,101
  • 13
  • 16
  • 25