Learn how to install a different version of Python on a Linux Ubuntu server. This guide covers simple steps to set up and use the version you need.
Prerequisites
- Linux Ubuntu Server
- SSH Access Enabled or Physical access to the server
Step-by-Step Guide to Install a Python Version
Most latest Linux Ubuntu Servers come with Python installed already. To check if python already installed, just run the below command.
python3 --version # or use python --version
You might get similar response like below – Tested on Linux Ubuntu Server 24.x.
Python 3.12.3
As a developer, you might want to install a different version of Python. For example, I want to install Python 3.10.14 for my old school projects. Below are the steps I will follow to install python 3.10.14 along with python 3.12.3. You would still be able to use both the versions.
1. Install prerequisites
sudo apt update
sudo apt install -y software-properties-common build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncursesw5-dev xz-utils tk-dev \
libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
2. Download and compile Python 3.10.x from source
cd /usr/src
sudo wget https://www.python.org/ftp/python/3.10.14/Python-3.10.14.tgz
sudo tar xzf Python-3.10.14.tgz
cd Python-3.10.14
sudo ./configure --enable-optimizations
sudo make -j$(nproc)
sudo make altinstall
make altinstall ensures it doesn’t overwrite the default python3 (which points to 3.12).
3. Now verify:
python3.10 --version
# Should output: Python 3.10.14
python3 --version
# Still shows Python 3.12.3
4. Use Python 3.10 in virtual environments
This is the best way to isolate different versions per project:
python3.10 -m venv ~/my-python-3.10-env
source ~/my-python-3.10-env/bin/activate
Now you’re using Python 3.10 just for that project. Use deactivate to exit the env.


Leave a Reply