Installing a custom version of Python 3

Overview

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.

To run the following commands, you must log in to your server via SSH with your Shell user. View the following articles for more information:

Installing Python 3

The instructions below install version 3.10.1. Make sure to change this to your chosen version in the commands below.

  1. Choose the version you wish to install from python.org.
  2. Right-click on the link titled Gzipped source tarball of the version you wish to install. From the popout menu choose Copy Link Address.
  3. Log into your server via SSH, and then run the following commands one at a time to configure Python:
    [server]$ cd ~
    [server]$ mkdir tmp
    [server]$ cd tmp
    [server]$ wget https://www.python.org/ftp/python/3.10.1/Python-3.10.1.tgz
    [server]$ tar zxvf Python-3.10.1.tgz 
    [server]$ cd Python-3.10.1 [server]$ ./configure --prefix=$HOME/opt/python-3.10.1
  4. Run the make commands to install Python.

    Shared servers only

    When installing custom versions of Python on a Shared server, specifically versions 3.8 to 3.11, you may encounter the following error:

    Resource temporarily unavailable

    To resolve this issue, set the -j6 flag using the following sed command. This command must be run right after the ./configure step above.

    [server]$ sed -i 's/-j0/-j6/g' Makefile*

    This edit permits up to six jobs to run concurrently during compilation, optimizing the use of system resources. This modification applies to the following three makefiles:

    • Makefile
    • Makefile.pre
    • Makefile.pre.in

    If issues persist after these changes, please reach out to customer support for further assistance.

    [server]$ make
    [server]$ make install
    These commands install your local version of python to /home/username/opt/python-3.10.1.
  5. Navigate back to your user's home directory:
    [server]$ cd ~
  6. 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:
    export PATH=$HOME/opt/python-3.10.1/bin:$PATH
  7. Save and close the file, and then return to your shell. Run the following command to update this file:
    [server]$ . ~/.bash_profile
  8. Check which version of Python you're now using by entering the following command:
    [server]$ python3 --version
    Python 3.10.1

    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.

Updating to a newer version

There is no quick option to automatically update your custom Python installation to a newer version.

You would follow the same steps above to download, install, and activate the version of your choice.

See also

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?