Python3 is available on Shared, VPS, and Dedicated servers. If you wish to use a specific version, you can install it locally under your Shell user by following the steps in this article.
Installing Python 3
- Choose the version you wish to install from python.org.
- Log into your server via SSH, and then run the following commands one at a time:
[server]$ cd ~ [server]$ mkdir tmp [server]$ cd tmp [server]$ wget https://www.python.org/ftp/python/3.9.2/Python-3.9.2.tgz [server]$ tar zxvf Python-3.9.2.tgz
[server]$ cd Python-3.9.2
[server]$ ./configure --prefix=$HOME/opt/python-3.9.2 [server]$ make [server]$ make install
- These commands install your local version of python to /home/username/opt/python-3.9.2.
- Navigate back to your user's home directory:
[server]$ cd ~
- View the creating and editing a file via SSH article for instructions on how to edit your existing .bash_profile. To use the new version of Python over the system default, enter the following line to your .bash_profile:
- Save and close the file, and then return to your shell. Run the following command to update this file:
[server]$ . ~/.bash_profile
- Check which version of Python you're now using by entering the following command:
[server]$ which python3 /home/username/opt/python-3.9.2/bin/python3
You can also check the version:
[server]$ python3 --version Python 3.9.2
If there is no response then the newly downloaded copy is not being used. Most often this is due to the .bash_profile not being updated correctly. Try logging out and back in again. If necessary, repeat the steps above.
If you're using Django
If you're using Django, make sure to view the following articles: