Page 1 of 1
Installing mod_python on apache
Posted: Sat Jun 16, 2007 8:09 pm
by smudge
Hello! So, I've been messing around with my server and decided to install a python module into apache, mod_python. Same thing as php, except python. I run the install binary I got off the website to install on windows, python 2.5.x, apache 2.2. All correct versions. The instructions said to add the line below to the apache config file:
Code: Select all
LoadModule python_module modules/mod_python.so
So I did, restart Apache, and... it dies. Do a test configuration, and it says there's a syntax error on that line, can't find mod_python.so. I check, and it's there all right. Any ideas on why this isn't working?
Re: Installing mod_python on apache
Posted: Sat Jun 16, 2007 11:54 pm
by volka
smudge wrote:I check, and it's there all right.
Exactly where?
And exactly what mod_python package did you download?
Posted: Sun Jun 17, 2007 9:38 am
by smudge
the file I downloaded is this:
mod_python-3.3.1.win32-py2.5-Apache2.2.exe
I have python 2.5.1 installed and working, and I'm running apache 2.2.
When I completed the install, I gave it the directory apache is installed in:
C:\Program Files\Apache Software Foundation\Apache2.2\
and it copied mod_python.so to:
C:\Program Files\Apache Software Foundation\Apache2.2\modules\mod_python.so
Posted: Sun Jun 17, 2007 11:18 am
by volka
Sorry, I'm clueless.
I've downloaded
http://www.apache.org/dist/httpd/modpyt ... che2.2.exe and the installation worked without any problem.
Posted: Sun Jun 17, 2007 11:37 am
by smudge
Yeah, It must be a system problem, because I just downloaded and installed again, with the same problem.
I commented the LoadModule line and apache ran perfectly. uncomment, syntax error, that line, can't find mod_python.so. I even double checked the file permissions in windows and gave full control to all users, no go.
Ok, just traveled all the way to the bin folder to do httpd -k start.
It says the file specified cannot be found. No installed service named Apache2
I thought I saw a thread here the other day doing something like
httpd -k uninstall Apache2
httpd -k install Apache2.2
(I don't know if that was exactly it)
Is that what I should do?
Posted: Sun Jun 17, 2007 11:49 am
by smudge
Ok, I just looked at that thread, and the command was
httpd -k uninstall -n Apache2.2
httpd -k install -n Apache2
I did that, and it told me the same error as the test configuration, it could not find the specified file. (not the same error as httpd -k start)
Posted: Sun Jun 17, 2007 12:35 pm
by volka
please download "Dependecy Walker" from
http://www.dependencywalker.com/ and run depends.exe.
call Options -> Configure module search order and add the path
C:\Program Files\Apache Software Foundation\Apache2.2\bin (so it can find libapr-1.dll, ...)
Then use file -> Open to load mod_python.so
Does it complain?
Posted: Sun Jun 17, 2007 12:44 pm
by smudge
It gave me
Warning: At least one delay-load dependency module was not found.
Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.
and in the 2nd row pane, it said
APPHELP.DLL: Error opening file. The system cannot find the file specified (2).
also, I've been doing a little research here. It seems that I need to reinstall some dot-net redistributables, and that might solve the problem, so I've been doing microsoft updates. I'll let you know how that works out when I've completed all the updates
Posted: Sun Jun 17, 2007 12:55 pm
by smudge
Ok, all of a sudden, Apache started to work again. Just to confirm, I started/stopped and restarted it many times. Yes, mod_python is not commented out. All I did was install windows 2000 service pack 4 and reboot. I will now test the installation using the script the website provides, then let you know how it goes. Thanks for the help.
Posted: Sun Jun 17, 2007 1:09 pm
by smudge
Ok, I did as the site told me to and added
<Directory /python>
AddHandler mod_python .py
PythonHandler mptest
PythonDebug On
</Directory>
to the httpd.conf file.
then I made a folder called python under htdocs, and a file called mptest.py:
Code: Select all
from mod_python import apache
def handler(req):
req.content_type = 'text/plain'
req.write("Hello World!")
return apache.OK
I went to 127.0.0.1/python/mptest.py and I got this:
Code: Select all
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
I checked the error log:
Code: Select all
[Sun Jun 17 13:58:56 2007] [error] make_obcallback: could not import mod_python.apache.\n
[Sun Jun 17 13:58:56 2007] [error] make_obcallback: Python path being used "['C:\\\\Python25\\\\python25.zip', '.\\\\DLLs', '.\\\\lib', '.\\\\lib\\\\plat-win', '.\\\\lib\\\\lib-tk', 'C:\\\\Program Files\\\\Apache Software Foundation\\\\Apache2.2\\\\bin']".
[Sun Jun 17 13:58:56 2007] [error] get_interpreter: no interpreter callback found.
[Sun Jun 17 13:58:56 2007] [error] [client 127.0.0.1] python_handler: Can't get/create interpreter., referer: http://127.0.0.1/python/
Posted: Sun Jun 17, 2007 4:49 pm
by volka
smudge wrote:It gave me
Warning: At least one delay-load dependency module was not found.
Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.
That's normal, nothing to worry about. If you didn't get a message box it's all fine.
There should be a link "Python (command line)" in your start menu.
What does it say when you enter
there?
And what does
print?
Posted: Mon Jun 18, 2007 2:51 pm
by smudge
the import says:
Code: Select all
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python25\Lib\site-packages\mod_python\apache.py", line 30, in <module>
import _apache
ImportError: No module named _apache
the print outputs
Code: Select all
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'sys' is not defined
Posted: Mon Jun 18, 2007 3:04 pm
by smudge
Ok, I did this and got the result:
Code: Select all
>>> import sys
>>> print sys.version
2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)]
Posted: Mon Jun 18, 2007 6:02 pm
by volka
Hm, looks both fine. Maybe you should ask in a python forum.
Posted: Mon Jun 18, 2007 7:47 pm
by smudge
Thanks for the help, volka. mod_python might not be working, but I've already built a simple web server in python.

I'm a fast learner

I'll work it out somehow. Consider this thread closed. Unless of course someone has a solution, then send me a pm. I'll answer it when I can.
Again, thanks a bunch for the help.