Dustin Mitchell
dustin at ywlcs.org
Thu May 29 08:45:00 EST 2003
On Thu, May 29, 2003 at 09:37:35PM +1000, Graeme Matthew wrote: > >>>from mod_python import apache > Traceback (most recent call last): > File "<stdin>", line 1, in ? > File "/usr/local/lib/python2.2/site-packages/mod_python/apache.py", line > 67, in ? > import _apache > ImportError: No module named _apache > >>>import mod_python > >>>from mod_python import apache The reason you don't get an error the next time is this: During the first import, Python partially loads and constructs the mod_python.apache module, until it gets to "import _apache", which causes an exception. However, at that point the mod_python.apache module is *loaded*, it's just not completely initialized. So when you get to the second from..import, Python finds that mod_python.apache is already loaded and simply returns a reference to the loaded (but still not initialized) module. The reason _apache can't be found is that it's the mechanism by which Python can communicate with the Apache process in which it is running. Since, at the command line, you're not running in an Apache process, there's no such module. Specifically, that module is provided by mod_python.so, which is loaded by Apache when it starts up, but not loaded or even referenced by the command-line-invoked Python. Dustin -- Dustin Mitchell dustin at ywlcs.org/djmitche at alumni.uchicago.edu http://people.cs.uchicago.edu/~dustin/
|