Joe Maller.com

Building Python on Shared Hosting

Why are there so few Google results for “Build Python on Shared Hosting?” Because it’s so ridiculously easy that it took me longer to write this post than it did to download, configure and compile Python 2.7 on two different shared hosting accounts.

These are the steps:

$ mkdir -p ~/opt/python-2.7
$ mkdir ~/src
$ cd ~/src
$ curl -LO http://www.python.org/ftp/python/2.7/Python-2.7.tgz
$ tar -xzvf Python-2.7.tgz
$ cd Python-2.7
$ ./configure --prefix=$HOME/opt/python2.7
$ make
$ make install

Next, create ~/opt/bin if it doesn’t exist already and symlink the new Python binary:

$ mkdir -p ~/opt/bin
$ ln -s ~/opt/python-2.7/bin/python2.7 ~/opt/bin/python

Finally, be sure your $SHELL’s $PATH is configured to look for binaries in ~/opt/bin. I use Bash, so I added the following line to ~/.bashrc:

export PATH=$HOME/opt/bin:$PATH

Ok, so why bother?

I’m lazy. I wanted to save myself a bunch of calls to file.close() by using the more modern with open syntax. Most shared hosts seem to consider Python unimportant, the two I use have Python 2.4.3 installed which is six years old. I couldn’t even import __future__ because __future__ hadn’t been written yet.

Waylan Limberg’s post about installing multiple versions of Python was helpful.

Update: Much has changed in a few years and Python support is finally coming around. A2 Hosting, whose shared servers run cPanel, has a page featuring Python shared hosting. Great to finally see all of this happening.


2 Responses to “Building Python on Shared Hosting” Comments Feed for Building Python on Shared Hosting

  • Excelent! Worked for me. Thanks so much for posting this! There’s a typo:

    tar -xzvf Python 2.6.5.tgz

    should be

    tar -xzvf Python-2.6.5.tgz

    • Fixed, thanks!

Leave a Reply