Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have no experience compiling code other than using Visual Studio's Build command. I am hoping we can create a step by step guide for compiling mod_python on windows. Please be as descriptive as possible.

This is what I've done so far:

  1. Download and install python 2.6.2
  2. Download and install apache 2.2.11
  3. Download the most recent source code for mod_python from svn

From here I'm lost to what the next step is. I've downloaded Microsoft Visual C++ 2008 Express Edition.

Errors messages I'm receiving from running the tutorial that brad mentioned.

C:\mod_python\dist>build_installer.bat Could Not Find C:\mod_python\src*.obj running bdist_wininst running build running build_py creating build creating build\lib.win32-2.6 creating build\lib.win32-2.6\mod_python copying C:\mod_python\lib\python\mod_python\apache.py -> build\lib.win32-2.6\mod _python copying C:\mod_python\lib\python\mod_python\cache.py -> build\lib.win32-2.6\mod_ python copying C:\mod_python\lib\python\mod_python\cgihandler.py -> build\lib.win32-2.6 \mod_python copying C:\mod_python\lib\python\mod_python\Cookie.py -> build\lib.win32-2.6\mod _python copying C:\mod_python\lib\python\mod_python\importer.py -> build\lib.win32-2.6\m od_python copying C:\mod_python\lib\python\mod_python\psp.py -> build\lib.win32-2.6\mod_py thon copying C:\mod_python\lib\python\mod_python\publisher.py -> build\lib.win32-2.6\ mod_python copying C:\mod_python\lib\python\mod_python\python22.py -> build\lib.win32-2.6\m od_python copying C:\mod_python\lib\python\mod_python\Session.py -> build\lib.win32-2.6\mo d_python copying C:\mod_python\lib\python\mod_python\testhandler.py -> build\lib.win32-2. 6\mod_python copying C:\mod_python\lib\python\mod_python\util.py -> build\lib.win32-2.6\mod_p ython copying C:\mod_python\lib\python\mod_python__init__.py -> build\lib.win32-2.6\m od_python running build_ext building 'mod_python_so' extension creating build\temp.win32-2.6 creating build\temp.win32-2.6\Release creating build\temp.win32-2.6\Release\mod_python creating build\temp.win32-2.6\Release\mod_python\src C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W 3 /GS- /DNDEBUG -DWIN32 -DNDEBUG -D_WINDOWS -IC:\mod_python\src\include -Ic:\apa che\include -IC:\Python26\include -IC:\Python26\PC /TcC:\mod_python\src\mod_pyth on.c /Fobuild\temp.win32-2.6\Release\mod_python\src\mod_python.obj mod_python.c c:\apache\include\ap_config.h(25) : fatal error C1083: Cannot open include file: 'apr.h': No such file or directory error: command '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe"' fa iled with exit status 2

share|improve this question
ahh...the tutorial doesn't say to, but you need the apache source in "C:\Apache" –  brad.lane Jul 27 '09 at 22:59
The build_installer.bat file should explicitly complain if the Apache source doesn't exist and then exit before doing anything, unless for some reason the check isn't working. If it isn't, it just reinforces how mod_python is slowly decaying and if possible alternatives investigated. –  Graham Dumpleton Jul 27 '09 at 23:11

2 Answers 2

up vote 2 down vote accepted

If I were you, I'd look if using mod_wsgi instead of mod_python is possible. (It usually is). mod_python has several issues and is unmaintained. No one has interest in it anymore. mod_wsgi on the other hand is an actively maintained and modern alternative. And there is a binary download available for you.

Yes, this is not a direct answer to your question but it is my honest opinion that having a look at mod_wsgi is better than messing around with mod_python, if possible.

share|improve this answer
Thanks, I'll check it out. –  John Jul 27 '09 at 22:17
yes, mod_python is kind of a relic at this point. all the cool new python stuff seems to target python's wsgi. –  brad.lane Jul 27 '09 at 23:03

Pulled from here:

Download the apache source code for the version you're targeting, and unzip it to "C:\Apache"

After installing python, make sure it is in your PATH

The SVN trunk will incluce a Windows build script for mod_python that builds two products, mod_python itself and "PSP", which stands for "Python Server Pages". The PSP build fails for me because of "@ARCHFLAGS@". I don't need PSP, so I disabled it in the build script.

In mod_python\dist\setup.py.in edit line 171 from: ext_modules = [ModPyModule, PSPModule] to: ext_modules = [ModPyModule]#, PSPModule]


Open a command prompt with VS2008 support. The easiest way to do this is to use "Start | All Programs | Microsoft Visual Studio 2008 | Visual Studio Tools | Visual Studio 2008 Command Prompt". (This puts the VS2008 binaries in the path and sets up the lib/include environmental variables for the Platform SDK.)

cd to the mod_python\dist folder.

Tell mod_python where Apache is: set APACHESRC=C:\Apache

Run build_installer.bat.

If it succeeds, an installer.exe will be created in a subfolder. Run that install the module.

share|improve this answer
Hi, I've tried this tutorial, but I've run into a problem where it reports that certain files could not be found. I updated the question to include the error messages. –  John Jul 27 '09 at 22:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.