[mod_python] ImportError: reload(): module ... not in sys.modules ?

Liam Hoekenga liamr at umich.edu
Wed Aug 29 10:28:36 EDT 2007


I'm a sysadmin who's part of a group that provides campus-wide web hosting 
at our university.  We're working with a faculty member who would like us 
to host an application he wrote in his departmental web environment and 
we're having issues.  Of course the application "just works" on his 
departmental machine, but when we try it on our box, the most current 
error we're getting is...

 	ImportError: reload(): module _mp_a52d922604fbb12687f4374d3c536a1b
 		not in sys.modules

Their departmental server is  using Apache 2.0.52, Python 2.3.4 and 
mod_python 3.1.3.

We're using Apache 2.2.3, Python 2.5, and mod_python 3.3.1.

I'm not a python programmer and this is my first forray in to mod_python. 
It kind of looks like from the rest of the debugging output that 
_mp_a52d922604fbb12687f4374d3c536a1b is the name of a "file" that 
mod_python has already processed an inserted into a cache.. and that 
perhaps that cache isn't in the python path?  I don't know.  Kinda 
grasping at straws here.

Here's our current mod_python configuration for the directory in question..

     Alias /pharmacy/ /home/pharmacy/Private/html/
    <IfModule mod_python.c>
        <Directory /home/pharmacy/Private/html/>
        AddHandler mod_python .py
        AllowOverride AuthConfig FileInfo Indexes Limit
        PythonAutoReload On
        PythonHandler /home/pharmacy/Private/html/python-program.py
        PythonDebug On
        </Directory>
     </IfModule>

If it does look like problems due to differences between the environments 
in which the application was developed and the where we're trying to 
deploy it, I'd be very appreciative for hints at what needs to be changed 
to make it work.  I'm very open to suggestions.

What follows are the excerpts from the apache error logs, and the output 
we see when we access the page with PythonDebug enabled.

Liam

--------------------------------------

Here's the appropriate output from the apache error log...

[Wed Aug 29 10:08:41 2007] [notice] mod_python (pid=6977, interpreter='example.umich.edu'): Importing module '/home/pharmacy/Private/html/python-program.py'
[Wed Aug 29 10:08:41 2007] [notice] mod_python (pid=6977, interpreter='example.umich.edu'): Importing module '/home/pharmacy/Private/html/tutor.py'
[Wed Aug 29 10:08:41 2007] [notice] mod_python (pid=6977, interpreter='example.umich.edu'): Importing module '/home/pharmacy/Private/html/lesson.py'
[Wed Aug 29 10:08:41 2007] [notice] mod_python (pid=6977, interpreter='example.umich.edu'): Importing module '/home/pharmacy/Private/html/tex.py'
[Wed Aug 29 10:08:45 2007] [error] [client xxx.xxx.xxx.xxx] mod_python (pid=6977, interpreter='example.umich.edu', phase='PythonHandler', handler='/home/pharmacy/Private/html/python-program.py'): Application error, referer: https://example.umich.edu/pharmacy/python-program.py
[Wed Aug 29 10:08:45 2007] [error] [client xxx.xxx.xxx.xxx] ServerName: 'example.umich.edu', referer: https://example.umich.edu/pharmacy/python-program.py
[Wed Aug 29 10:08:45 2007] [error] [client xxx.xxx.xxx.xxx] DocumentRoot: '/usr/share/apache2/htdocs/default/', referer: https://example.umich.edu/pharmacy/python-program.py
[Wed Aug 29 10:08:45 2007] [error] [client xxx.xxx.xxx.xxx] URI: '/pharmacy/python-program.py', referer: https://example.umich.edu/pharmacy/python-program.py
[Wed Aug 29 10:08:45 2007] [error] [client xxx.xxx.xxx.xxx] Location: None, referer: https://example.umich.edu/pharmacy/python-program.py
[Wed Aug 29 10:08:45 2007] [error] [client xxx.xxx.xxx.xxx] Directory: '/home/pharmacy/Private/html/', referer: https://example.umich.edu/pharmacy/python-program.py
[Wed Aug 29 10:08:45 2007] [error] [client xxx.xxx.xxx.xxx] Filename: '/home/pharmacy/Private/html/python-program.py', referer: https://example.umich.edu/pharmacy/python-program.py
[Wed Aug 29 10:08:45 2007] [error] [client xxx.xxx.xxx.xxx] PathInfo: '', referer: https://example.umich.edu/pharmacy/python-program.py
[Wed Aug 29 10:08:45 2007] [error] [client xxx.xxx.xxx.xxx] Traceback (most recent call last):, referer: https://example.umich.edu/pharmacy/python-program.py
[Wed Aug 29 10:08:45 2007] [error] [client xxx.xxx.xxx.xxx]   File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1537, in HandlerDispatch\n    default=default_handler, arg=req, silent=hlist.silent), referer: https://example.umich.edu/pharmacy/python-program.py
[Wed Aug 29 10:08:45 2007] [error] [client xxx.xxx.xxx.xxx]   File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1229, in _process_target\n    result = _execute_target(config, req, object, arg), referer: https://example.umich.edu/pharmacy/python-program.py
[Wed Aug 29 10:08:45 2007] [error] [client xxx.xxx.xxx.xxx]   File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1128, in _execute_target\n    result = object(arg), referer: https://example.umich.edu/pharmacy/python-program.py
[Wed Aug 29 10:08:45 2007] [error] [client xxx.xxx.xxx.xxx]   File "/home/pharmacy/Private/html/python-program.py", line 224, in handler\n    s = coord.initHistory(session, formd), referer: https://example.umich.edu/pharmacy/python-program.py
[Wed Aug 29 10:08:45 2007] [error] [client xxx.xxx.xxx.xxx]   File "/home/pharmacy/Private/html/python-program.py", line 132, in initHistory\n    reload(tutor)\t# Force the current version of tutor module to be used., referer: https://example.umich.edu/pharmacy/python-program.py
[Wed Aug 29 10:08:45 2007] [error] [client xxx.xxx.xxx.xxx] ImportError: reload(): module _mp_a52d922604fbb12687f4374d3c536a1b not in sys.modules, referer: https://example.umich.edu/pharmacy/python-program.py

--------------------------------------

Here's what we get when we access the page with PythonDebug turned on...

...continuing old session

...POST reading: uniqname=bjensen&lessonchoice=Minimal&startup=Start
...cwd='/'
...ls=['lost+found', 'var', '.bash_history', '.authorize', 'afs',  'bin', 'boot', 'dev',
'etc', 'home', 'lib', 'mnt', 'proc', 'root',  'sys', 'sbin', 'ticket', 'tmp', 'usr',
'opt', 'man']
MOD_PYTHON ERROR

ProcessId:      22409
Interpreter:    'example.umich.edu'

ServerName:     'example.umich.edu'
DocumentRoot:   '/usr/share/apache2/htdocs/default/'

URI:            '/pharmacy/python-program.py'
Location:       None
Directory:      '/home/pharmacy/Private/html/'
Filename:       '/home/pharmacy/Private/html/
crippen/python-program.py'
PathInfo:       ''

Phase:          'PythonHandler'
Handler:        '/home/pharmacy/Private/html/
crippen/python-program.py'

Traceback (most recent call last):

   File "/usr/lib/python2.5/site-packages/mod_python/importer.py",  line 1537, in
HandlerDispatch
     default=default_handler, arg=req, silent=hlist.silent)

   File "/usr/lib/python2.5/site-packages/mod_python/importer.py",  line 1229, in
_process_target
     result = _execute_target(config, req, object, arg)

   File "/usr/lib/python2.5/site-packages/mod_python/importer.py",  line 1128, in
_execute_target
     result = object(arg)

   File "/home/pharmacy/Private/html python-program.py",
line 224, in handler
     s = coord.initHistory(session, formd)

   File "/home/pharmacy/Private/html python-program.py",
line 132, in initHistory
     reload(tutor)        # Force the current version of tutor module to be  used.

ImportError: reload(): module _mp_a52d922604fbb12687f4374d3c536a1b  not in sys.modules


MODULE CACHE DETAILS

Accessed:       Tue Aug 28 17:47:07 2007
Generation:     4

_mp_036881b8bfdae0dbd53cd31522b8613c {
   FileName:     '/home/pharmacy/Private/html/ crippen/lesson.py'
   Instance:     1
   Generation:   1
   Modified:     Wed Mar  7 13:53:05 2007
   Imported:     Tue Aug 28 17:26:23 2007
}

_mp_6e0a86c977aa7b4821de3f2e456eeb4d {
   FileName:     '/home/pharmacy/Private/html/
crippen/python-program.py'
   Instance:     1
   Generation:   4
   Modified:     Tue Aug 28 17:26:02 2007
   Imported:     Tue Aug 28 17:26:23 2007
   ModulePath:   '/home/pharmacy/Private/html/'
   Children:     '/home/pharmacy/Private/html/ crippen/tutor.py'
}

_mp_251123f760a2485b75c77026f93acd83 {
   FileName:     '/home/pharmacy/Private/html/ crippen/tex.py'
   Instance:     1
   Generation:   2
   Modified:     Fri Mar 30 09:39:23 2007
   Imported:     Tue Aug 28 17:26:23 2007
}

_mp_a52d922604fbb12687f4374d3c536a1b {
   FileName:     '/home/pharmacy/Private/html/ crippen/tutor.py'
   Instance:     1
   Generation:   3
   Modified:     Tue Aug 21 15:16:35 2007
   Imported:     Tue Aug 28 17:26:23 2007
   Children:     '/home/pharmacy/Private/html/ crippen/lesson.py',
                 '/home/pharmacy/Private/html/ crippen/tex.py'
}



More information about the Mod_python mailing list