Python

Python is a popular programming langauge used by some programs. The programs will depend on specific versions. This guide provides an easy way to specify the Python version running on your slot.

You'll need to execute some commands via SSH to use this software. There is a separate guide on how to connect to your slot via SSH. Commands are kept as simple as possible and in most cases will simply need to be copied and pasted into the terminal window (then executed by pressing the Enter key).

Table of contents

Installation

Python is already installed on your server.

If you require a more recent version, copy and paste the SSH commands below. If you want to install a specific version then modify the version=3.9.2 line.

version=3.9.2
# Download
wget "https://www.python.org/ftp/python/$version/Python-$version.tgz"
tar -zxvf "Python-$version.tgz"
rm "Python-$version.tgz"
cd "Python-$version"
# Install
./configure --prefix=$HOME/python
make
make altinstall
cd ..
rm -r "Python-$version"
majMin="${version%.*}"
ln -s "$HOME/python/bin/python${majMin}" ~/python/bin/python
ln -s "$HOME/python/bin/pip${majMin}" ~/python/bin/pip

The folder ~/python/bin will be in your $PATH. This means that when Python installs programs to this folder, they will be used over other installations.

Usage

After installation you will find that python runs your installed version. You can check to see the version installed by running the Python command:

python -V

The installation will also make pip available. If you need to use it, please see see its own guide.

Uninstallation

The install keeps everything in the folder ~/python and creates two links (python and pip) under ~/bin

This can be done with the SSH command:

rm -rf ~/python ~/bin/python ~/bin/pip