This article describes how to configure and use a newer Python version. You may want to do this if:
Depending on the managed server where your account is located, there may be an older version of Python installed. If you want to run a newer version of Python, you can compile it from the source code.
To compile Python from the source code, follow these steps:
cd ~ wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz tar xvzf Python-3.8.0.tgz cd Python-3.8.0 ./configure --prefix=$HOME make make install
To configure your shell environment to use the new compiled executable, type the following commands. Replace username with your own A2 Hosting account username:
echo 'alias python3="/home/username/bin/python3.8"' >> ~/.bashrc
source ~/.bashrc
To confirm your account is configured to use the new version, type the following command:
python3 --version
If you want to create virtual environments using your new installed Python version, you must first install the virtualenv program. To do this, type the following commands:
cd ~/bin python3.8 -m pip install virtualenv
You can then create a virtual environment by running the virtualenv program in the bin directory. For example, to create a virtual environment named testenv, type the following command:
~/bin/virtualenv testenv
To activate the new environment, type the following command:
source testenv/bin/activate
The package repositories for your Linux distribution may contain an older version of Python. If you want to run a newer version of Python, you can compile it from the source code. To do this, follow these steps:
cd ~ wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz tar xvzf Python-3.8.0.tgz cd Python-3.8.0 ./configure make make install
To configure the shell environment to use the new compiled executable, type the following commands. Replace executable_path with the path to the compiled Python executable (for example, /usr/local/bin):
echo 'alias python3="/executable_path/python3.8"' >> ~/.bashrc
source ~/.bashrc
To confirm your account is configured to use the new version, type the following command:
python3 --version
For more information about Python, please visit https://www.python.org.
Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.
We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.