Installing a custom version of Python

As of August 2015, DreamHost currently runs Python v2.7.3.

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

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

  1. Log into your web server via SSH.
  2. Run the following command to download your desired version of Python:
    [server]$ wget http://www.python.org/ftp/python/2.7.7/Python-2.7.7.tgz
  3. Decompress the .tar file you downloaded:
    [server]$ tar zxvf Python-2.7.7.tgz 
  4. Change your directory into the Python version folder you just downloaded:
    [server]$ cd Python-2.7.7 
  5. 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.
  6. Include the path in order to use this version of Python over the system default by adding the following to your .bash_profile file which is located in your user’s directory:
    export PATH=$HOME/opt/python-2.7.7/bin:$PATH
    
  7. Run the following to update to .bash_profile:
    [server]$ . ~/.bash_profile
  8. Check which version of Python you're now using:
    [server]$ python -V

    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 https://bootstrap.pypa.io/get-pip.py > ~/tmp/get-pip.py python ~/tmp/get-pip.py --user
    

See also