schram.net

Installing Python on Hurricane Electric servers

(Note that I'm now using pair.com for hosting, but I'm leaving this up for a while.)

Hurricane Electric (he.net) is an Internet Service Provider (ISP) providing web space with shell and full programming environment access. However, my favorite programming language, Python, is not preinstalled. This article explains how to install it.

You need to know how to use telnet and ftp to administer your account, if not, read the he.net FAQ.

Download the Python source file from python.org. In my case, the file is named Python2.2.tgz.

Telnet to your he.net account. This procedure will no doubt take a lot of CPU time, it would be considerate to do it during non-peak hours.

Substitute your actual user name for "yourusername" throughout.

Create a directory src under your home directory (/home/yourusername/src).

FTP the Python source file to that directory. If you're using FTP from Microsoft Windows, be sure you upload it in binary mode, or it will be corrupted.

Unpack and compile the source:

~/src$ gunzip Python-2.2.tgz

~/src$ tar -xf Python-2.2.tar

~/src$ cd Python-2.2

~/src/Python-2.2$ ./configure

~/src/Python-2.2$ make

During the compilation, I get lots of warnings about "time.h" and a couple other header files. Two files failed to build: _curses_panel and linuxaudiodev. I'm not going to need those two for web development, so I'm ignoring it. At this point, you could "make test". For me, it caused a segmentation fault when testing "test_strftime". Probably, this test should work, but fixing this is an exercise left for the student.

Edit the freshly created Makefile and change prefix = /usr/local to /home/yourusername/local

Create the directory (not sure if this is needed.)

~/src/Python-2.2$ mkdir /home/yourusername/local

~/src/Python-2.2$ make install

~/src/Python-2.2$ cd ~/local/bin

~/local/bin$ ./python

Python should run, without any error messages.

>>> print "hello"
hello

Type: Ctrl-D to exit the Python shell.

Python CGI Tests

Create the following two files in your ~/cgi-bin directory. Remember to "chmod +x *.py" to make the files executable.

test1.py:

#!/home/yourusername/local/bin/python
print "Content-type: text/plain"
print ""
print "We love Guido!"

test2.py:

#!/home/yourusername/local/bin/python

import cgi
cgi.test()

You can run these files directly first:

$ ~/cgi-bin/test1.py

test2.py outputs an HTML page which contains a lot of useful information about the CGI programming enviroment.

If they work, then try accessing them from the web:

http://yourdomain/cgi-bin/test1.py

Reducing Disk Usage

he.net will charge you extra for disk usage if you exceed the quota for your account (averaged over the month), so you may want to delete some of the unnecessary files.

After compilation, the ~/src directory is about 70mb. You can delete the entire src directory.

The ~/local directory is using about 25mb. If desired, you can delete some of the modules under the lib directory that you're unlikely to use for web development: test, distutils, config, lib-tk are possiblities. If you're not sure whether deleting something will break Python, use FTP to download the entire ~/local directory and archive it so you can upload it again later if you need it.


Questions, comments? Email me (the address in the graphic at the top.)

© 2006 Scott Schram (Disclaimer)