[mod_python] frustrating problem importing packages with mod_python

Stephen Potenza steve at potenzaconsulting.com
Thu May 26 17:08:28 EDT 2005


I setup a simple mod_python publisher and it's working perfectly.

[index.py]
def index():
    return "hi from index"

When I access it through http://localhost/python/, I see "hi from
index"... everything works fine.


However, when I try import a module from a package I created named
"steve", I get the following error:

-------------------------------------------------------------------
Mod_python error: "PythonHandler mod_python.publisher"

Traceback (most recent call last):

  File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line
299, in HandlerDispatch
    result = object(req)

  File "/usr/lib/python2.3/site-packages/mod_python/publisher.py", line
98, in handler
    path=[path])

  File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line
457, in import_module
    module = imp.load_module(mname, f, p, d)

  File "/var/www/python/index.py", line 1, in ?
    from steve import dummy

ImportError: No module named steve
-------------------------------------------------------------------

[index.py]
from steve import dummy

def index():
    return dummy.say()

if __name__ == "__main__":
    print index()


The "steve" package/directory contains two files:

- __init__.py (blank)
- dummy.py

[dummy.py]
def say():
    return "this is dummy!"

When I run index.py from the command line, it works perfectly. Any ideas??

Thanks,
Steve


More information about the Mod_python mailing list