Skip to content

Configuring and using a newer version of Python

This guide explains how to download, compile, and configure a newer Python version on your hosting account. This is useful if the server’s default Python version is older than what your application requires.

  • Managed servers (shared or reseller) where the installed Python version is older than required.
  • Unmanaged servers where package repositories contain older Python versions.
  • You must have a compiler and development tools installed on your server.

Configuring a newer Python version on managed servers

Section titled “Configuring a newer Python version on managed servers”
  1. Log in to your account using SSH.
  2. Download and extract the Python source code:
cd ~
wget https://www.python.org/ftp/python/3.12.8/Python-3.12.8.tgz
tar xvzf Python-3.12.8.tgz
cd Python-3.12.8
  1. Compile and install Python to your home directory:
./configure --prefix=$HOME
make
make install
  1. Configure your shell to use the new Python version (replace username with your account username):
echo 'alias python3="/home/username/bin/python3.12"' > ~/.bashrc
source ~/.bashrc
  1. Verify the new Python version:
python3 --version

Python 3 includes built-in support for virtual environments using the venv module.

  • To create a virtual environment:
python3 -m venv testenv
  • To activate it:
cd testenv && source bin/activate

Configuring a newer Python version on unmanaged servers

Section titled “Configuring a newer Python version on unmanaged servers”

If the system repositories have an older Python version, you can compile it from source:

  1. Log in to your server via SSH as root.
  2. Download and extract the source code:
cd ~
wget https://www.python.org/ftp/python/3.12.8/Python-3.12.8.tgz
tar xvzf Python-3.12.8.tgz
cd Python-3.12.8
  1. Compile and install:
./configure
make
make install
  1. Configure your shell to use the new executable (replace executable_path with the path to the compiled Python executable, e.g., /usr/local/bin):
echo 'alias python3="/executable_path/python3.12"' > ~/.bashrc
source ~/.bashrc
  1. Confirm the Python version:
python3 --version

For further details about Python versions, downloads, and documentation, visit Python.org.