This article was last edited over 3 years ago. Information here may no longer be accurate. Please proceed with caution, and feel free to contact me.
These instructions worked for me on my BlueHost instance, but I cannot guarantee they will work for everyone. Luckily, gcc, g++, make, and every utility that I needed to install Python 2.7 were already present in my case.
In order for this to work, enable SSH on your Bluehost.com account and verify that you can connect to your server, then follow the directions below.
Connect to your server by SSH
Navigate to your home directory. Because this is a shared hosting environment we do not have access to system-wide resources, but we can do almost anything we want in the $HOME directory
Create a bin, opt, and src directory to contain our (bin) binaries and executable commands, (opt) optional compiled software, and (src) setup files and source code.
mkdir bin opt src
Change to the src directory where we will download source code and installation files
Download the latest version of Python (2.7.2 at the time of writing)
Untar (unzip) the Python 2.7 source code
tar xzvf Python-2.7.2.tgz
Change into the directory with the Python 2.7 source code
Run the configure script and specify the destination folder for the Python 2.7 compiled code. Notice that the compiled Python 2.7 code will end up inside the opt directory we made earlier
Finish the installation
make && make install
Create a symbolic link in the $HOME/bin directory that points to the python2.7 binary we compiled
ln -s $HOME/opt/python27/bin/python2.7 $HOME/bin/python2.7
Create another symbolic link so that the “python” command in $HOME/bin will link to the python2.7 binary
ln -s $HOME/bin/python2.7 $HOME/bin/python
I prefer nano, but use your text editor of choice to update your $PATH variable
Update your PATH variable as follows. It’s important that the $HOME/opt/python27/bin and $HOME/bin entries come before $PATH so that typing ‘python’ favors running our newly compiled python over BlueHost’s built in Python 2.4 binary
Update the $PATH variable on-the-fly so we don’t have to log out and in for our changes to take effect
Confirm that the binary being used for python is your $HOME/bin/python command
Verify that your Python version is 2.7.2
python --version Python 2.7.2
Change to the $HOME/src directory again
Download get-pip.py, a wonderful script we will use to install pip and setuptools.
Install pip (the script will figure out where to install pip for our custom python version)
Verify you can execute pip. If this works, then you now have Python 2.7 and pip, a Python package manager, up and running. You can use pip to easily install Python packages. I’ll be writing another article soon to explain how to write and serve a simple Python application on BlueHost