Bluehost is my hosting provider for http://thegreenplace.net
I’m generally quite happy with them – the service is stable and the support is responsive. A small annoyance is the old version of Python they have installed by default – 2.3.4. This is quite an old version and many libraries have already dropped support for it.
Luckily, installing a local version of Python is very easy. Here are the few simple steps required to install the latest and greatest Python and run your CGI scripts with it (I’m installing version 2.5.2 in this example).
Access your account with SSH and in the home directory execute:
wget http://www.python.org/ftp/python/2.5.2/Python-2.5.2.tgz tar xvzf Python-2.5.2.tgz
This downloads and unzips the Python 2.5.2 source distribution. Now install Python locally to your home directory, executing:
cd Python-2.5.2 ./configure -prefix=/home/username/python252 --enable-unicode=ucs4 make make install
Replace username/python252 with your username on the host’s server and the target directory you want to install into. This operation will take a couple of minutes, depending on your server’s speed. It fully configures, compiles and installs Python from sources.
The next step is making the Python you’ve just installed the default Python in your shell. Open ~/.bashrc  and add this line at the end:
Save and close the file. New bash shells will now have Python 2.5.2 respond to python. To make it happen in the current shell, type bash, and then python -V to see the new version.
Now, it is important to modify all your Python scripts (including CGI ones) to be executed with your private Python. Modify the shebang line at the top of the scripts to point to it:
That’s about it ! Your Python CGI scripts will now run with Python 2.5.2
Since you’ve made Python 2.5.2 the default in your shell, you can now easily install new Python modules into its site-packages and use them in your scripts. Simply download the modules with wget and install them with python setup.py install. easy_install will work too, once you install it.
P.S. I expect this method, perhaps with minor modifications, to work for other providers as well, and not only Bluehost.
|||Assuming bash is your shell. For other shells, adapt the example accordingly.|