Building Python/Mapscript
Building mapscript for python on Linux
First build the appropriate python and install it (2.4.2 for me) Then build the python library like so
cd mapserver-4.6.1 cd mapscript/python cp modern/* . python setup.py build
You can run the included tests once it builds
cd tests/cases python runalltests.py -v
Unit testing! Hey, I think I might grow to like python. Once the tests indicate all is well, install mapscript.
cd ../.. python setup.py install
Apache problem
Aside from enabling Python to run CGI scripts as in the python.cgi, I had a problem with the PYTHONHOME environment variable. Because I already had Python 2.2.3 installed as part of the operating system, I wanted to install Python 2.4 in a different location (/usr/local instead of /usr) and enable it for Apache scripts. When I ran the initial script (python.cgi) it worked but the mapscript.cgi example could not find its libraries.
To fix this, I set the PYTHONHOME variable in my Apache configuration file, like this:
SetEnv PYTHONHOME /usr/local
I put this line in the VirtualHost section that I use for mapserver so that it will allow me to use Python 2.4 anywhere in that server but not affect other parts of the Apache installation (like other customers sharing the same computer.)
That's it. The iMap test should run now.