Installing a custom version of Python

As of May 2017, DreamHost currently runs Python v2.7.3.

To install a custom version of Python, you must download it from

For the following commands, replace VERSION with the version of Python you wish to install.

  1. Log into your web server via SSH.
  2. Visit the downloads page above. Right click the link titled "Gzipped source tarball" for the version you wish to install. From the dropdown choose "Copy link address".
  3. In your terminal, type 'wget' and paste the link you just copied. This is what it will look like:
    [server]$ wget
  4. Decompress the .tar file you downloaded:
    [server]$ tar zxvf Python-2.7.7.tgz 
  5. Change your directory into the Python version folder you just downloaded:
    [server]$ cd Python-2.7.7 
  6. Run the following to install. For example, to install Python 2.7.7:
    [server]$ ./configure --prefix=$HOME/opt/python-2.7.7
    [server]$ make
    [server]$ make install
    • This installs your local version of Python to /home/<username>/opt/python-2.7.7.

Change the python version your shell uses

Now that python is installed, you must add an alias to your .bash_profile file. Once added, you can type 'python' and it will use your newly installed version.

  1. Navigate to your user's home directory.
    [server]$ cd $HOME
  2. Add the following line to your .bash_profile file. Make sure to adjust the line to show your actual username and version of python:
    alias python='/home/USERNAME/opt/python-3.6.1/bin/python3'

    NOTE: The alias above assumes you installed python 3.6.1. Make sure to adjust the line to reflect the version you actually installed.

  3. Run the following to update to .bash_profile:
    [server]$ . ~/.bash_profile
  4. Add the following line to your .bashrc file:
    source .bash_profile
  5. Check which version of Python you're now using:
    [server]$ python -V

When you now type in the command 'python', it will use the version you just installed.

pip installation

In order to install various Python packages, and Django in particular, you'll want pip. This is pre-installed on shared servers, but if necessary, you can use the following to download:

[server]$ curl > ~/tmp/ python ~/tmp/ --user

See also

Did this article answer your questions?

Article last updated .