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
🌐
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 from the PPA. This adds a versioned python3.12 command beside Ubuntu 22.04’s original Python 3.10 interpreter.
🌐
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 - 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 ... Thanks for the article, works for me at 06/2025. Darktable Released 5.6.0 with Optional ...
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
Install python 3.11.9 on ubuntu
I have installed guest VM ubuntu-22.04.4-desktop-amd64.iso on a Windows 10 host. In the VM, I have run the following: sudo apt install sudo apt upgrade this: python3 --version returns: Python 3.10.12 When I run: sudo apt install python3 I receive this message: python3 is already at the newest ... More on discuss.python.org
🌐 discuss.python.org
12
1
April 16, 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
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
🌐
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 - Use /usr/bin/python3.14 on Ubuntu 26.04 LTS, /usr/bin/python3.12 on Ubuntu 24.04 LTS, or /usr/bin/python3.10 on Ubuntu 22.04 LTS. # Example for Ubuntu 24.04 LTS when apt is broken sudo ln -sf /usr/bin/python3.12 /usr/bin/python3 sudo apt install --reinstall python3-minimal · After the repair, keep invoking Python 3.10 explicitly with python3.10 rather than modifying the python3 symlink again.
🌐
BitLaunch
bitlaunch.io › blog › how-to-install-python-on-ubuntu
7 Ways to Install and Manage Python and Python3 on Ubuntu
March 5, 2026 - Ubuntu 24.04 (Noble): Python 3.12 ... versions · On Ubuntu, the easiest and officially recommended way is to install the python-is-python3 package....
🌐
PhoenixNAP
phoenixnap.com › home › kb › sysadmin › how to install python 3 on ubuntu
How to Install Python 3 on Ubuntu | phoenixNAP KB
February 5, 2025 - 2. Navigate to the official Python source code webpage and select the program version you want to install. Scroll down to the Files section and copy the link to the Gzipped source tarball: 3. Use the wget command and the link above to download ...
🌐
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
🌐
LinuxTuto
linuxtuto.com › home › how to install python 3.12 on ubuntu 22.04
How to Install Python 3.12 on Ubuntu 22.04 - LinuxTuto
October 2, 2023 - Selection Path Priority Status ... /usr/bin/python3.10 1 manual mode 2 /usr/local/bin/python3.12 2 manual mode · Press <enter> to keep the current choice[*]. Now check the default version using the below command: ... That is it! You are now set to use Python 3.12 to build web applications, software development, create workflows e.t.c · In the tutorial, you have learned how to install Python 3.12 on Ubuntu 22.04 using ...
🌐
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.

🌐
Time4vps
help.time4vps.com › all collections › vps tutorials › various tutorials › how to install python 3.12 on ubuntu/debian
How To Install Python 3.12 on Ubuntu/Debian | Time4VPS Help Center
August 7, 2025 - Be cautious when using it on applications relying on the default Python version. Install essential tools for managing software properties. ... Install Python version 3.12 from the added repository.
🌐
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 - Installing Python 3.10 on Ubuntu using APT is quite easy, a big thumbs up to the deadsnakes custom PPA!
🌐
TecAdmin
tecadmin.net › how-to-install-python-3-12-on-ubuntu
How to Install Python 3.12 on Ubuntu 24.04 / 22.04 / 20.04 – TecAdmin
April 26, 2025 - You can install them by running the following command: sudo apt install -y software-properties-common build-essential libffi-dev libssl-dev zlib1g-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev libgdbm-dev libdb5.3-dev libbz2-dev libexpat1-dev liblzma-dev libffi-dev libssl-dev
🌐
Medium
medium.com › @KNuggies › install-python-3-12-on-ubuntu-c7674df5f623
Install Python 3.12 on Ubuntu
June 13, 2024 - Install Python 3.12 on Ubuntu In this short article, we’ll install Python 3.12 on Ubuntu by building the Python source code! These same steps apply if you want to install Python 3.12 on WSL 2.0 …
🌐
Python
python.org › downloads
Download Python | Python.org
Python 3.11.12 April 8, 2025 Download Release notes · Python 3.11.11 Dec. 3, 2024 Download Release notes · Python 3.11.10 Sept.
🌐
Python.org
discuss.python.org › python help
Install python 3.11.9 on ubuntu - Python Help - Discussions on Python.org
In the VM, I have run the following: sudo apt install sudo apt upgrade this: python3 --version returns: Python 3.10.12 When I run: sudo apt install python3 I receive this message: python3 is already at the newest ...
Published   April 16, 2024
🌐
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 ...
🌐
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 - In first line, change #!/usr/bin/python3 to #!/usr/bin/python3.12. Press Ctrl +X followed by enter to save and exit. Then save and close the file. Next, update the default Python by adding both versions to an alternatives by running the below ...
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.

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.