Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

How to Use a Newer Version of Python

Your server may come with an older Python. This guide shows how to install a newer one next to it, without breaking anything. You need root access, so it suits VPS and dedicated server customers.

Web Hosting2 min read10 steps

Why a second version?

Python is a programming language. It has versions, like 3.8 or 3.11. Some apps need a newer one. But the server's own tools may need the old one. If you replace the old one, those tools can break. So we install the new one beside it.

Two safe ways are shown below. The first uses your system's package tool. The second uses a virtual environment. A virtual environment is a private box for one project, with its own Python and packages.

Warning: Do not delete or replace the system Python. Many server tools depend on it. Take a backup or snapshot first.

Step 1: Check what you have

python3 --version

This command prints the Python 3 version on your server.

Step 2: Install a newer version

On Ubuntu or Debian, you can often install one from the package list:

  1. Log in with SSH. SSH is a safe way to type commands on a faraway server.
  2. Update the package list:
    sudo apt update
  3. Search for versions:
    apt search python3.11
    This command shows if that version is offered. Replace the number with the version you want.
  4. Install it:
    sudo apt install python3.11 python3.11-venv

On CentOS or AlmaLinux, use sudo yum install or sudo dnf install with the package name your system offers. If your system does not list the version, build it from the source files on python.org or ask Hostvento support.

Step 3: Use it in a virtual environment

  1. Go to your project folder:
    cd ~/myproject
  2. Create the environment:
    python3.11 -m venv myenv
    This command makes a private box named myenv that uses Python 3.11.
  3. Turn it on:
    source myenv/bin/activate
  4. Check the version:
    python --version
    It should now show the new version.
  5. Install packages with pip install name. They stay inside this box.
  6. Leave the box when you finish:
    deactivate

Quick recap

  • Install the new Python next to the old one.
  • Never remove the system Python.
  • Use python3.x -m venv to make a private environment.
  • Use source myenv/bin/activate to enter it.
  • Ask Hostvento support if your server cannot find the version you want.