Installing Python Mapscript on Windows XP

Sean Gillies sgillies at FRII.COM
Tue May 3 09:45:40 EDT 2005


Good news.  You should read about Apache's SetEnv directive.  It will
help you properly set the PYTHONPATH, PATH, and FWTools environments
for use with Apache.

cheers,
Sean

On May 3, 2005, at 6:34 AM, Bas Vanmeulebrouk wrote:

> Hi everyone,
>
> I finally got Pyhton Mapscript up and running. After I had installed
> the
> FWTools version, I still had the same problem. However, the cgitb tip =
> proved
> very useful. Now I could see which dll was missing and it was the =
> mapscript
> module. Apparently, Apache couldn't find it (I think it doesn't =
> recognize
> the PythonPath environment variable). But it did find the cgitb
> module, =
> so I
> put mapscript.py, _mapscript.pyd and mapscript.pyc in the same
> directory =
> as
> cgitb.py. And now Python Mapscript is working just fine.=20
>
> This is what I have done:
> - Install Apache HTTP server 1.3
> - Install FWTools 0.9.6=20
> - Configure Apache so that it will run Python scripts as CGI =
> (httpd.conf)
> - Fiddle around with the path and pythonpath environment variables and
> =
> dll
> names to get Mapscript working from the Python command line
> - Copy mapscript.py etc. as explained earlier.
>
> Maybe I will look into this last step. I don't think it is a very neat
> solution, but for now I am just glad evrything is working. Thank you =
> very
> much for your help!
>
> Kind regards,
>
> Bas Vanmeulebrouk.=20
>
> -----Original Message-----
> From: Sean Gillies [mailto:sgillies at frii.com]=20
> Sent: Friday, April 29, 2005 6:08 PM
> To: Bas Vanmeulebrouk
> Cc: MAPSERVER-USERS at LISTS.UMN.EDU
> Subject: Re: Installing Python Mapscript on Windows XP
>
>
> Bas,
>
> Look at Python's cgitb module.  It will allow your CGI script to
> return  =
>
> a more informative traceback.
>
> Another thing to check is that the PATH, PROJ_LIB, and other variables
> =20
> are properly set for the Apache user's environment.
>
> Sean
>
>
> On Apr 29, 2005, at 8:04 AM, Bas Vanmeulebrouk wrote:
>
>> Hello Howard,
>>
>> Thank you very much for reaction. I thought I had downloaded the
>> Python Mapscript build without SDE and Oracle support, but of course
>> I =
>
>> may be mistaken.=3D20
>>
>> I have solved the gdal12.dll problem. And when I run a Python script
>> in which I use "import mapscript", everything runs fine. I can create
>> =
> a
>> new
>> mapObj and save it to an image. However, if I call this script via the
>> Apache webserver, I get the internal server error.=3D20
>>
>> I have downloaded the FWTools package and I will try it next week.
>>
>> Kind regards,
>>
>> Bas.
>>
>> -----Original Message-----
>> From: Howard Butler [mailto:hobu at iastate.edu]=3D20
>> Sent: Thursday, April 28, 2005 6:16 PM
>> To: Bas Vanmeulebrouk; MAPSERVER-USERS at LISTS.UMN.EDU
>> Subject: Re: Installing Python Mapscript on Windows XP
>>
>>
>> Bas,
>>
>> Regarding the SDE depencency in my MapScript builds.... you need to
>> be =
>
>> =3D very=3D20
>> careful to get the exact Python MapScript you need.  As you can see
>> on =
> =20
>> =3D
>> my=3D20
>> website, there are *four* Python MapScript builds.  At one time, you =
> =3D
>> must=3D20
>> have chosen either the "SDE" or "Full" build, which both have the =20
>> SDE=3D20
>> dependency.  Use the "Normal" release at all times unless you have a =
> =3D
>> need=3D20
>> (and the dlls) for either SDE or Oracle.
>>
>> Regarding the extra gdal12.dll's in C:\python23\ and=20
>> C:\python23\dlls... =3D
>>
>> The Python uninstaller doesn't deal with dlls in the main
>> sys.prefix=3D20 directory very well on Windows (especially in an=20
>> uninstall-reinstall=3D20 cycle).  I've had to manually delete these =
> after an
> uninstall of
>> Python=3D20
>> MapScript (using the control panel).  Python 2.4 (which I don't =20
>> provide=3D20
>> builds for) does better at this, and will uninstall dlls in the =
> DLLs=3D20
>> directory.  Uninstall all of the mapscripts that you have using the =
> =3D
>> control=3D20
>> panel and then go into the python23 directory and delete the dlls =
> by=3D20
>> hand.  This will clean up your Python directory.  If you have =
> other=3D20
>> gdal12.dlls, you'll either have to move the PATH, clean them up, or
>> =20
>> do=3D20
>> something with them as you see fit.
>>
>> Regarding the issue of not seeing which dll python can't find...
>> run=20
>> the =3D
>>
>> python script using a command window (dos prompt), rather than IDLE=20
>> or=3D20 Activestate.  The IDEs swallow the dialog for some reason.
>>
>> FWTools is more cleanly packaged than my mapscript binaries=3D20
>> <http://fwtools.maptools.org/>.  It comes with its own Python
>> and=3D20 =
>
>> everything else you might need.  I suggest you try it if you continue
>> to =3D
>>
>> have trouble with my binaries.
>>
>> Howard
>>
>>
>> At 10:32 AM 4/28/2005, Bas Vanmeulebrouk wrote:
>>> Frank,
>>>
>>> Thank you very much for your reaction. I did rename the one in the
>>> windows/system32 directory. However, I didn't notice that there
>>> were=3D20
>>> two gdal12.dll's in the Python installation directory: one in the =20
>>> root=3D20
>>> and =3D3D one in the DLLs subdirectory. I have renamed the one in
>>> the =
> =3D
>> DLLs=3D20
>>> =3D3D subdirectory
>>> and after that got a different error message (now sde90.dll was =3D3D
>>> missing).=3D3D20
>>>
>>> This errormessage always appeared, no matter from what location I =
> =3D3D
>>> started Python. Sde90.dll was on my machine, in the
>>> C:\Program=3D20=20
>>> Files\Common\ESRI directory. After I had added this directory to
>>> the=3D20
>>> PATH environment variable, Python Mapscript was finally working. =20
>>> But=3D20
>>> does this mean =3D3D Python
>>> Mapscript needs some ESRI files? The ones I have came with the =3D3D
>>> installation
>>> of ESRI MapObjects 2.3.=3D3D20
>>>
>>> I want to use Python/Mapscript to generate a map and some HTML which
>>> can =3D3D be displayed in webbrowser. So I thought I should get =
> a=3D20=20
>>> Python/Mapscript =3D3D script which does this to work as a CGI =
> script.=20
>>> I can get Apache to execute a Python CGI script, but when I
>>> include=20
>>> the line "import mapscript", I =3D
>> get =3D3D
>>> an
>>> internal server error and the following error messages in the Apache
>>> =3D
>> =3D3D
>>> error
>>> log.=3D3D20
>>>
>>> Traceback (most recent call last):\n
>>>    File "c:\\PROGRA~1\\APACHE~1\\apache\\cgi-bin\\HELLO_~1.PY", line
>>> 4, =3D3D in ?\n
>>>      import mapscript\n
>>>    File "C:\\programs\\python23\\Lib\\site-packages\\mapscript.py", =
> =3D
>> line =3D3D
>>> 4,
>>> in ?\n
>>>      import _mapscript\n
>>> ImportError: DLL load failed: The specified module could not be =3D
>> found.\n
>>>
>>> I don't have a clue which dll is missing this time. Anyone? Or is=20
>>> there another way to achieve this?
>>>
>>> Kind regards,
>>>
>>> Bas Vanmeulebrouk.=3D3D20
>>>
>>> -----Original Message-----
>>> From: Frank Warmerdam [mailto:fwarmerdam at gmail.com]=3D3D20
>>> Sent: Thursday, April 28, 2005 2:19 PM
>>> To: Bas Vanmeulebrouk
>>> Cc: MAPSERVER-USERS at lists.umn.edu
>>> Subject: Re: [UMN_MAPSERVER-USERS] Installing Python Mapscript on =
> =3D3D
>>> Windows XP
>>>
>>>
>>> On 4/28/05, Bas Vanmeulebrouk <bvanmeul at ebe.uct.ac.za> wrote:
>>>> =3D3D20
>>>> Hi list,
>>>>  =3D3D20
>>>> I have been trying to get Python Mapscript up and running on =
> MS=3D3D20
>>>> Windows XP, but I haven't succeeded yet. I have downloaded
>>>> the=3D3D20=3D20
>>>> binaries at http://hobu.stat.iastate.edu/mapserver/. When I =3D
>> start=3D3D20=3D20
>>>> Python from the directory in which I have installed Python,=3D20
>>>> Mapscript=3D3D20 works fine. However, if I start Python from=20
>>>> another=3D20 directory, I get=3D3D20 the following error message =
> when I try
>>>> import=3D20
>>>> mapscript at the Python=3D3D20 command line: "The procedure =
> entry=3D20
>>>> point=3D3D20 ?SetnextByIndex at OGRLayer@@UAEHJ at Z could not be located
>>>> =
> in =20
>>>> =3D
>>
>>>> the dynamic=3D3D20 link library gdal12.dll.".  =3D3D20
>>>> I have found four copies of gdal12.dll on my machine. I have =3D
>> been=3D3D20
>>>> exeprimenting with the PATH environment variable, I have renamed =3D
>> the=3D3D20
>>>> various dll's, but the message stays the same.
>>>>  =3D3D20
>>>> Does anyone have an idea what might be wrong?
>>>
>>> Bas,=3D3D20
>>>
>>> I am guessing that one of the 4 gdal12.dll's is in =3D
>> windows\system32,=3D3D20
>>> right?  This location takes precidence over the PATH, but even=20
>>> higher=3D20 precidence is the directory the program is running =
> in.=3D3D20
>>>
>>> I would suggest you move or rename the version in =3D
>> windows\system32.=3D3D20
>>>
>>> Best regards,
>>> ---------------------------------------
>>> +-------------------------------
>>> ---------------------------------------+-
>>> ---------------------------------------+------
>>> I set the clouds in motion - turn up   | Frank Warmerdam,
>>> warmerdam at pobox.com
>>> light and sound - activate the windows | http://pobox.com/~warmerdam
>>> and watch the world go round - Rush    | Geospatial Programmer for
>>> =20
>>> Rent
>>
>



More information about the mapserver-users mailing list