Adding a Python Version
On this site, you will find a step-by-step guide on adding a custom Python Version to the instance.
We will add an older version Python 3.8, to our instance as an example.
The first and easiest solution for Ubuntu users would be to import the deadsnakes team Launchpad PPA.
This will always contain the latest updates for Python and all extra packages that may be required.
- Install the prerequisite for adding custom PPAs:
apt update && apt -y install software-properties-common
- Add the deadsnakes/ppa to your APT package source list:
add-apt-repository ppa:deadsnakes/ppa -y
- Install Python 3.8:
apt update && apt -y install python3.8
First, we need to install the required dependencies to be able to build Python 3.8 from the source.
apt update && apt -y install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev libbz2-dev
#Compiling from Source
All Python Releases can be found on the following site: https://www.python.org/downloads/
- Download the source for Python 3.8.
- Extract the downloaded tarball:
tar xf Python-3.8.13.tgz
- Configure with the flag --enable-optimizations:
cd Python-3.8.13./configure --prefix=/usr --enable-optimizations
- Run make to start the compile process:
- Install Python 3.8 via altinstall, which maintains the default Python binary path in /usr/bin/python.
- Remove the source and the tgz:
rm -rf Python-3.8.13 Python-3.8.13.tgz
- Done! Python 3.8 has been installed and is now available to select in CloudPanel.
apt --purge remove zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libreadline-dev libffi-dev libsqlite3-dev libbz2-dev