How to Install Python 3.10 on Ubuntu (24.04, 22.04, 20.04) – Step-by-Step Guide
Python is a popular, versatile programming language beloved by developers for everything from web development to data science. While most Ubuntu distributions come with Python pre-installed, the default version might not always be the latest. If you’re looking to install Python 3.10 on Ubuntu 24.04, 22.04, or 20.04, you’re in the right place. This guide will walk you through the process step-by-step, helping you get Python 3.10 up and running on your system smoothly.
Why Install Python 3.10?
Table of Contents
Each new version of Python brings a host of exciting features and significant performance improvements. Python 3.10 introduces:
- Structural Pattern Matching
- Parenthesized Context Managers
- Improved error messages
- Precise types with typing module enhancements
These features make Python 3.10 a compelling choice for developers who want to stay on the cutting edge.
Step-by-Step Guide to Installing Python 3.10
1. Update Your System
First, it’s essential to update your package list and installed packages for a clean start:
sudo apt update
sudo apt upgrade
2. Install Required Dependencies
Install the tools and libraries needed to build Python from source:
sudo apt install -y software-properties-common \
build-essential libssl-dev zlib1g-dev libncurses5-dev \
libnss3-dev libsqlite3-dev libreadline-dev libffi-dev \
libbz2-dev liblzma-dev uuid-dev libgdbm-dev libgdbm-compat-dev wget
3. Download Python 3.10 Source Code
Go to the official Python website or use wget
to download directly from the command line:
wget https://www.python.org/ftp/python/3.10.13/Python-3.10.13.tgz
tar -xvf Python-3.10.13.tgz
cd Python-3.10.13

4. Compile and Install Python
Now it’s time to build Python 3.10. This step will take a few minutes:
./configure --enable-optimizations
make -j$(nproc)
sudo make altinstall
Note: We use altinstall
instead of install
to prevent overwriting the system’s default Python version.
5. Verify the Installation
Once installed, verify that Python 3.10 is working:
python3.10 --version
You should see output similar to:
Python 3.10.13
6. Optional: Set Python 3.10 as Default
If you want to use Python 3.10 as your default python3
interpreter, you can use the update-alternatives
command:
sudo update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.10 1
sudo update-alternatives --config python3
You will then be prompted to select the version you wish to use by default.
Troubleshooting Tips
- Missing Dependencies: If you see errors during the configure step, double-check that all development libraries are installed.
- Compatibility Issues: Be cautious when replacing system Python, especially if you rely on system tools like
apt
, which depend on it.

Using Virtual Environments
To avoid system-wide conflicts, it’s highly recommended to use Python virtual environments:
python3.10 -m venv myenv
source myenv/bin/activate
This keeps dependencies isolated and makes it easier to manage multiple projects using different Python versions or libraries.
Conclusion
Installing Python 3.10 on Ubuntu 24.04, 22.04, or 20.04 is a manageable task even for beginner developers. Whether you’re eager to explore the newest language features or just need 3.10 for compatibility reasons, this guide should have made the process simple and clear. Remember to use virtual environments and altinstall
to keep your system both stable and flexible.
With Python 3.10 installed, you’re all set to take advantage of its performance improvements and exciting new syntax features. Happy coding!