How to fix Python3.10 error on Ubuntu 22.04

md flag

Im having some issue after updating ubuntu from v20 to v22, and i really need your help.

I surely messed up some python files, and now the vast majority of 'apt' command wont work at all.

Since i already had problems with my ubuntu-desktop, i though i would reinstall it. Problem is, it did uninstall properly, but i can't install it, i always get the same python error :

python3 : Depends: libpython3-stdlib ( = 3.10.11-1+focal1) but it is not going to be installed

python3.10 : Depends: libpython3.10-stdlib (= 3.10.11-1+focal1) but it is not going to be installed

python3.10-minimal : Depends : libpython3.10-minimal (=3.10.11-1+focal1) but it is not going to be installed```

Basically, i've tried everything i could come across online.

Not any apt/apt-get/purge/autoremove/fix-broken,... command work add-apt-repository is broken too

So now im basically stuck on a CLI only ubuntu that can't install anything, and i really don't have a clue on what to do.

While trying to restore my computer I might have messed it up even more than it was, and i might have multiple python installed now, but im not even sure how to check on that.

cn flag

One method: Back up your data, then clean-install Ubuntu 22.04.

"i've tried everything i could come across online" is too vague to understand what you might have done, and a reinstall will be much faster for most folks than the troubleshooting that you don't know how to do anyway.

Going forward, there are two safe ways to have different versions of Python co-exist without destroying your system. You should master at least one of them. It's too late to use them on your current system -- the damage is already done.

  1. Virtualization
  2. Proper use of update-alternatives
Green绿色 avatar
ng flag
(ana)conda and pyenv also allow you to install and use multiple versions of Python on the same system in parallel.
gh flag

Before you try this make a backup of your important data and make a propper install media for jammy!

mkdir $HOME/backup/

Then we move sources.list's from foreign packages sources in this folder.

sudo mv /etc/apt/sources.list.d/* $HOME/backup/

Then we make a backup from your old sources.list.

sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak

Create a new one

deb jammy main restricted

deb jammy-updates main restricted

deb jammy universe
deb jammy-updates universe

deb jammy multiverse
deb jammy-updates multiverse

deb jammy-security main restricted
deb jammy-security universe
deb jammy-security multiverse
deb jammy partner

When we try over apt pinning to force packages to jammy version. Create

sudo nano /etc/apt/preferences.d/jammy.pref

with following content.

Package: *
Pin: release n=jammy
Pin-Priority: 1001

Refresh package cache

sudo apt update

First a simulation from partial upgrade Note this is the debian way.

apt -s upgrade

Check the output carefully. If apt tells you are doing something dangerous (remove essential packages) Stop. And install anew like @user535733 told.

If no errors

sudo apt upgrade

Then next simulation

sudo apt -s full-upgrade

Check the ouput again before you make the command for real.

sudo apt full-upgrade

Note this is a dangerous attempt to fix your installation. That's why it is so important to make a backup before and a functional install media.

laptel avatar
md flag
Thanks for your help. Sadly, sudo apt upgrade keep failing for the same python3 unmet dependencies :/
nobody avatar
gh flag
`sudo apt update && sudo apt -f install --reinstall python3=3.10.6-1~22.04` my last idea.
I sit in a Tesla and translated this thread with Ai:


Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.