Changing Python version on linux server
October, 24, 2025Recently, Python 3.14 LTS has been released. So, it's time for an upgrade. And if you have a running project, I strongly recommend updating it to the newer version from time to time. It will ease support and development, and save you a lot of headaches in the future.
First, check the current Python version:
python --version
# Python 3.13.3
Delete old version:
# See what /usr/local has
ls -l /usr/local/bin/python3*
readlink -f /usr/local/bin/python3 2>/dev/null || true
type -a python3
# Remove the binaries/symlinks in /usr/local/bin
sudo rm -f /usr/local/bin/python3 /usr/local/bin/python3.* \
/usr/local/bin/pip3 /usr/local/bin/pip3.*
hash -r # clear shell command cache
# Find & delete any stragglers under /usr/local
sudo find /usr/local -maxdepth 3 -name 'python3*' -print
# If the list looks right:
# sudo find /usr/local -maxdepth 3 -name 'python3*' -exec rm -rf {} +
# Verify you’re now using the system Python
which python3
python3 --version
ls -l /usr/bin/python3
Load the latest Python version and update packages:
wget https://www.python.org/ftp/python/3.14.0/Python-3.14.0.tgz;
sudo apt update && sudo apt upgrade -y;
Make sure all of the build requirements are installed:
sudo apt install -y make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
libncurses5-dev libncursesw5-dev xz-utils tk-dev
Build and Install Python:
tar xvf Python-3.14.0.tgz
cd Python-3.14.0/
This command unpacks the source code into a directory named after the TAR file. Note that the TAR file will show a specific Python version.
Now you need to run the ./configure script to prepare the build:
./configure --enable-optimizations --with-ensurepip=install
The enable-optimizations flag will enable some optimizations within Python to make it run faster. Doing this may add twenty or thirty minutes to the compilation time. The with-ensurepip=install flag will install pip bundled with this installation.
Next, you build Python using the make command. The -j option allows you to tell make to split the building into parallel steps to speed up the compilation. Even with the parallel builds, this step can take several minutes. Note: Use all logical cores like this; if you pass more cores than are available, it will get stuck.
make -j"$(nproc)"
And install the new version:
sudo make altinstall
And Voilà, we have a new version installed :)
python3.14.0 --version