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.
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:
- Log in with SSH. SSH is a safe way to type commands on a faraway server.
- Update the package list:
sudo apt update - Search for versions:
This command shows if that version is offered. Replace the number with the version you want.apt search python3.11 - 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
- Go to your project folder:
cd ~/myproject - Create the environment:
This command makes a private box namedpython3.11 -m venv myenvmyenvthat uses Python 3.11. - Turn it on:
source myenv/bin/activate - Check the version:
It should now show the new version.python --version - Install packages with
pip install name. They stay inside this box. - 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 venvto make a private environment. - Use
source myenv/bin/activateto enter it. - Ask Hostvento support if your server cannot find the version you want.