So finally I found out how to install Python 3.10 from sources

dependencies needed for building:

sudo apt install -y build-essential libssl-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libffi-dev zlib1g-dev

Download and extract the sources

cd /opt
sudo wget https://www.python.org/ftp/python/3.10.12/Python-3.10.12.tgz
sudo tar -xvf Python-3.10.12.tgz

Compile and Install

cd Python-3.10.12
sudo ./configure --enable-optimizations
sudo make altinstall
Answer from Vincent Tschanz on askubuntu.com
🌐
GitHub
gist.github.com › rutcreate › c0041e842f858ceb455b748809763ddb
Install Python 3.10.x on Ubuntu 20.04 - Gist - GitHub
sudo apt-get update sudo apt-get install -y --no-install-recommends \ build-essential \ curl \ wget \ libssl-dev \ zlib1g-dev \ libncurses5-dev \ libncursesw5-dev \ libreadline-dev \ libffi-dev \ libsqlite3-dev \ libbz2-dev \ liblzma-dev \ tk-dev ...
Discussions

Correct way to install Python 3.12 on Ubuntu 24.04 (with pip & venv)?
Don't use apt to install python. Never, ever. No version control, too much delay to stick with new versions. If you want to do it manually, install them from the tarball, on python website. If you want to do it more easily, use pyenv, it will handle everything for you, including dark shenanigans with dependencies. Later on, check for other version control tools, like pipenv or poetry. You don't have to use them, but it's nice to understand. More on reddit.com
🌐 r/PythonLearning
17
6
May 30, 2025
need to install python3.10
In case you don't get an answer, perhaps try Easy Diffusion? https://easydiffusion.github.io/ More on reddit.com
🌐 r/Ubuntu
7
2
April 29, 2024
How can I completely remove and re-install python3.10 that is located in ~/.local ? (Ubuntu 22.04)
Use rye or uv when you reinstall - they make it a pleasure to work with Python. More on reddit.com
🌐 r/learnpython
6
5
October 25, 2024
Installing Python 3.10
Do you really need a full Ubuntu image? Ubuntu 20.04 uses Debian Bullseye (according to: https://askubuntu.com/a/445496/170138 ). I doubt there's anything you need from Ubuntu in a Docker container that's not in Debian. If Debian suffices, use python:3.10-bullseye and call it a day. More on reddit.com
🌐 r/learnpython
3
4
February 2, 2024
🌐
GitHub
gist.github.com › stas00 › d6851b7dc631c44fa273873d1332dc1e
Install Python 3.10.x on Ubuntu 20.04 · GitHub
sudo apt install python3.10 python3.10-venv python3.10-dev python3 --version · You will see previous of Python. At the writing time Python 3.8.10
🌐
UbuntuHandbook
ubuntuhandbook.org › home › howtos › how to install python (3.15 beta) in ubuntu 26.04, 24.04, 22.04
How to Install Python (3.15 Beta) in Ubuntu 26.04, 24.04, 22.04 | UbuntuHandbook
1 month ago - Since venvs are so strongly encouraged ... I was looking for that actually. and since there’s no venv, I guess I’ll stick with 3.10 ... $ sudo apt-get install python3.12-venv $ python3.12 -m venv venv $ source venv/bin/activate $ pip install...
🌐
ComputingForGeeks
computingforgeeks.com › home › how to install python 3.10 on ubuntu 22.04|20.04|18.04
How To Install Python 3.10 on Ubuntu 22.04|20.04|18.04 [Guide]
March 21, 2026 - With the deadsnakes repository added to your Ubuntu system, now download Python 3.10 with the single command below. ... ................... Building dependency tree Reading state information...
🌐
LinuxCapable
linuxcapable.com › home › ubuntu › how to install python 3.10 on ubuntu 26.04, 24.04 and 22.04
How to Install Python 3.10 on Ubuntu 26.04, 24.04 and 22.04 - LinuxCapable
May 11, 2026 - Install Python 3.10 on Ubuntu 26.04, 24.04 and 22.04 via official repos, Deadsnakes PPA or source. Covers pip, venv, troubleshooting.
🌐
DebugPoint
debugpoint.com › home › dev › how to install python 3.12 in ubuntu and other linux
How to Install Python 3.12 in Ubuntu and Other Linux
January 9, 2024 - Planning to get Python 3.12 installed for your project work? Here's how to install Python 3.12 in Ubuntu and other Linux distributions.
Find elsewhere
🌐
Reddit
reddit.com › r/pythonlearning › correct way to install python 3.12 on ubuntu 24.04 (with pip & venv)?
r/PythonLearning on Reddit: Correct way to install Python 3.12 on Ubuntu 24.04 (with pip & venv)?
May 30, 2025 -

What’s the right way to install Python 3.12 on Ubuntu 24.04, with pip and venv working out of the box?

I tried:

sudo apt install python3.12.3

But it didn’t include pip or venv, and I hit an “externally managed environment” error when using pip in a venv.

Should I be using:

sudo apt install python3-full

or:

sudo apt-get install python3 python3-dev instead?

Just looking for the cleanest, correct way to get a working Python dev setup on this version of Ubuntu — any clarification appreciated.

🌐
GitHub
gist.github.com › luizomf › 8623264cbf69cd2619bcdee258628f41
Instalação Python 3.10 Ubuntu 22.04 · GitHub
sudo apt update -y sudo apt upgrade -y sudo apt install git curl build-essential -y sudo apt install gcc make default-libmysqlclient-dev libssl-dev -y sudo apt install python3.10-full python3.10-dev -y sudo apt install python3-venv ... Mais atualizado, único que consegui instalar... sudo apt update -y sudo apt upgrade -y sudo apt install git curl build-essential -y sudo apt install gcc make default-libmysqlclient-dev libssl-dev -y sudo apt install python3.12-full python3.12-dev -y sudo apt install python3-venv ... Uso o Mint, o meu da um erro, quando vejo a versão ta na 3.8.10, e quando executo o comando para a versão recente da esse erro:
🌐
BitLaunch
bitlaunch.io › blog › how-to-install-python-on-ubuntu
7 Ways to Install and Manage Python and Python3 on Ubuntu
March 5, 2026 - Learn the best ways to install Python on Ubuntu, including how to install pip, pyenv, and Anaconda on Ubuntu to safely manage your Python 3 versions.
🌐
CloudBytes
cloudbytes.dev › home › snippets › upgrade python to latest version (3.14) on ubuntu linux or wsl2
Upgrade Python to latest version (3.14) on Ubuntu Linux or WSL2 · CloudBytes/dev
April 13, 2026 - This will install the specified version of Python. Start a discussion on GitHub if you’ve got questions or improvements.
🌐
LinuxCapable
linuxcapable.com › home › ubuntu › how to install python 3.12 on ubuntu 26.04, 24.04 and 22.04
How to Install Python 3.12 on Ubuntu 26.04, 24.04 and 22.04 - LinuxCapable
May 7, 2026 - Install Python 3.12 on Ubuntu 26.04, 24.04 and 22.04 via official repos, Deadsnakes PPA or source. Covers pip, venv, security updates.
Top answer
1 of 2
2

I discovered this issue after trying the steps described in this article, which claims support for 20.04 | 22.04 | 23.04.

TL;DR straight to the fix:

echo "deb https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu/ jammy main" | sudo tee /etc/apt/sources.list.d/deadsnakes-ubuntu-ppa-lunar.list
sudo apt update
sudo apt install python3.12

The journey to get there:

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.12

However, as mentioned in the comments above, there is no "lunar" release in their apt ppa, and the apt update command fails. To resolve this, change the contents of /etc/apt/sources.list.d/deadsnakes-ubuntu-ppa-lunar.list (installed by add-apt-repository) from:

deb https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu/ lunar main
# deb-src https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu/ lunar main

to

deb https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu/ jammy main
# deb-src https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu/ jammy main

This tells apt to install packages for 22.04 ("jammy"), which seems to work just fine on 23.04 for this package.

Then you can just run apt update and apt install python3.12 successfully

2 of 2
0

Use a virtual environment to resolve your issue.

  • Updating Python in Ubuntu can cause compatibility issues with system components and applications. Ubuntu relies on specific Python versions for its internal processes, and updating Python could disrupt these dependencies.

  • Use a Python Version Manager: Consider using a Python version manager like Pyenv or asdf to manage multiple Python versions on your system. These tools allow you to install and switch between different Python versions easily, and you can create virtual environments with any installed Python version.

Let me know if any further information is needed.

🌐
DebugPoint
debugpoint.com › home › apps › how to install python 3.10 in ubuntu and other related linux
How to Install Python 3.10 in Ubuntu and Other Related Linux
October 22, 2022 - Step-by-step guide on how to install Python 3.10 in Ubuntu Linux, with screenshots. Also contains details to set up default Python.
🌐
GitHub
gist.github.com › ant1fact › 8fdacea1b925ec9219cb04467783b18c
Install python3.10 as python on ubuntu 20.04 · GitHub
# Setup sudo apt update && sudo apt upgrade -y sudo apt install software-properties-common -y sudo add-apt-repository ppa:deadsnakes/ppa -y # Python 3.11 sudo apt install python3.11 sudo apt install python3.11-dev sudo apt install ...
Top answer
1 of 1
19

First

Never delete or replace the official Python version installed in Ubuntu Linux! It's a mistake of the author of the article you followed, that you can remove unneeded versions of Python after installing Python 3.12. You could never remove the official one. For Ubuntu 22.04 it's 3.10.

In your situation, I don't believe you already deleted the official Python 3.10. You have just removed it from python or python3 alternatives by the update-alternatives program. You can restore APT to a working state again just by running a set of commands like:

  • sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.10
  • sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10

Or similar. I hope you will get the docs of update-alternatives and find out the way how to restore your 3.10 Python version in the list of alternatives.

You still can have a few versions installed, along with the official one, and added them all to the alternatives. This will allow your IDEs and other software to see and choose which version to use.

Second

The problem with not installing Python 3.12 fully is because of the incorrectly updated Python package (3.12.1) by the authors of the source repository - deadsnakes. They need to rebuild it with the resolution in order to the core policies which make it unable to be installed (SyntaxError: from __future__ imports must occur at the beginning of the file). I don't see any other ways except the 2 following:

  • wait for the resolution by repo authors
  • raise this issue with them via official communication ways

As an example, raising this issue can be done on their main issue tracker on GitHub. After they fix the package, you will be able to just run sudo apt update && sudo apt upgrade to get the newest Python 3.12.1 updated fully.

🌐
GitHub
gist.github.com › MichaelCurrin › 57caae30bd7b0991098e9804a9494c23
How to install Python 3 · GitHub
Debian/Ubuntu (for other Linux distros, see this Gist). Install using apt-get. $ sudo apt-get update $ sudo apt-get install python3 # OR python3.12