2

I am having issues with getting my Mod Python to work properly.

I have followed mod_python manual found here

So here is my Apache setup (I am using Virtual Hosts):

<VirtualHost *:80>
 ServerName hostname
 DocumentRoot "C:/Documents and Settings/username/hostname/www"
 <Directory "C:/Documents and Settings/username/hostname">
 DirectoryIndex index.py
 AddHandler mod_python .py
 PythonHandler www.index
 PythonDebug On
 </Directory>
</VirtualHost>

Here is my handler index.py:

from mod_python import apache
def handler(req):
 req.content_type = "text\plain"
 req.write("Hello World!")
 return apache.OK

After setting all that up I get the following error:

ImportError: No module named www.index

NOTE: The reason I am adding www to index, is because that is what the mod_python tutorial stated:

Attempt to import a module by name myscript. (Note that if myscript was in a subdirectory of the directory where PythonHandler was specified, then the import would not work because said subdirectory would not be in the sys.path. One way around this is to use package notation, e.g. "PythonHandler subdir.myscript".)

If I use mod_python.publisher as my PythonHandler, everything works fine. Not sure what I am missing here.

asked Sep 30, 2010 at 14:06

2 Answers 2

1

I figured it out. My Directory did not match my DocumentRoot.

I appreciate the replies regarding mod_wsgi. I will eventually move to wsgi but I am still learning how to use Python for web development and I basically defaulted to learn using mod_python.

answered Sep 30, 2010 at 14:41
Sign up to request clarification or add additional context in comments.

1 Comment

Bad choice. Switch now so you can focus on web development, not administration of a product that's not used much.
0

If you can stop using mod_python as it is abandoned now. mod_wsgi is the way to go.

answered Sep 30, 2010 at 14:14

3 Comments

you are not answering the question of the OP
Yes, he is and very well. Lark is just following the mod_python tutorial, so it is very relevant to point him to mod_wsgi and save him some hair pulling.
This answer is not an answer, but it is relevant information. Maybe it would work better as a comment to the original post.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.