[mod_python] weird import problems with mod_python

Graham Dumpleton graham.dumpleton at gmail.com
Tue Oct 30 20:24:27 EDT 2007


Upgrade to mod_python 3.3.1. The older version you are using is buggy.
For all the gory details of why you shouldn't be using such an old
version read:

  http://www.dscpl.com.au/wiki/ModPython/Articles/ModuleImportingIsBroken

Graham

On 31/10/2007, Rajarshi Guha <rguha at indiana.edu> wrote:
> Hi, I'm running Apache 2.0.2, Python 2.3.4 on a RHEL 4 machine and
> mod_python 3.1.3
>
> I have a mod_python program, junk.py, that looks like
>
> import sys
> import calc
>
> def index(req):
>      return sys.path
>
> Here calc is a Python file in the same directory as junk.py. Thus I
> expected that it would import with no problem. If I comment out the
> import calc line I get the value of sys.path as
>
> ['/home/*/public_html/', '/usr/lib/python23.zip', '/usr/lib/
> python2.3', '/usr/lib/python2.3/plat-linux2', '/usr/lib/python2.3/lib-
> tk', '/usr/lib/python2.3/lib-dynload', '/usr/lib/python2.3/site-
> packages', '/usr/lib/python2.3/site-packages/gtk-2.0', './']
>
> If however the import calc line is uncommented then visiting the URL
>
> http://sulu.informatics.indiana.edu/~rguha/junk.py/
>
> will report:
>
> 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 "/home/rguha/public_html/junk.py", line 5, in ?
>
> ImportError: No module named calc
>
> But then reloading that URL will then show the expected result.
> Reloading once more shows
>
> 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 "/home/rguha/public_html/junk.py", line 5, in ?
>      def index(req):
>
> ImportError: No module named calc
>
>
> THis is very weird and I can't seem to work out what's happening -
> sometimes it will load and work, other times it will throw an
> ImportError but at different places.
>
> Any pointers would be very much appreciated!
>
>
> -------------------------------------------------------------------
> Rajarshi Guha  <rguha at indiana.edu>
> GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04  06F7 1BB9 E634 9B87 56EE
> -------------------------------------------------------------------
> A meeting is an event at which the minutes are
> kept and the hours are lost.
>
>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
>


More information about the Mod_python mailing list