[mod_python] mod_python claims it cannot find a module

Martin MOKREJŠ mmokrejs at ribosome.natur.cuni.cz
Mon Jul 4 11:02:53 EDT 2005


I'll make a small testcase if you wish. The code breaks in the latter case on very
first line of my code where is

import web_settings

with ImportError: No module named web_settings


In the former error 
IOError: [Errno 2] No such file or directory: '/home/mmokrejs/public_html/IRES2/index.py'
it breaks even before executing my code, as python
handler looks for index.py which doesn't even exist. I have to tell
apache that it shouldn't even look for index.py with that configuration
directive. Still don't understand why when I'm accessing
http://aquarius/~mmokrejs/IRES2/IRESite_web.py and not http://aquarius/~mmokrejs/IRES2/

Martin


Julien wrote:
> can you paste your code to http://rafb.net/paste/ ?
> 
> On Mon, 2005-07-04 at 16:24 +0200, Martin MOKREJŠ wrote:
> 
>>Hi,
>>  when I have in httpd.conf:
>>
>><IfDefine PYTHON>
>>  <IfModule !mod_python.c>
>>    LoadModule python_module    modules/mod_python.so
>>  </IfModule>
>></IfDefine>
>>
>><IfModule mod_python.c>
>>
>>AddHandler mod_python .py
>>PythonHandler mod_python.publisher
>>PythonInterpPerDirectory On
>>PythonDebug On
>>
>>
>>and no .htaccess in my public_html directory and access
>>http://aquarius/~mmokrejs/IRES2/IRESite_web.py?page=all, I get:
>>
>>
>>Mod_python error: "PythonHandler mod_python.publisher"
>>
>>Traceback (most recent call last):
>>
>>  File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 299, in HandlerDispatch
>>    result = object(req)
>>
>>  File "/usr/lib/python2.4/site-packages/mod_python/publisher.py", line 187, in handler
>>    module = page_cache[req]
>>
>>  File "/usr/lib/python2.4/site-packages/mod_python/cache.py", line 77, in __getitem__
>>    return self._checkitem(name)[2]
>>
>>  File "/usr/lib/python2.4/site-packages/mod_python/cache.py", line 118, in _checkitem
>>    opened = self.check(key, name, entry)
>>
>>  File "/usr/lib/python2.4/site-packages/mod_python/publisher.py", line 67, in check
>>    return ModuleCache.check(self, key, req, entry)
>>
>>  File "/usr/lib/python2.4/site-packages/mod_python/cache.py", line 249, in check
>>    opened = file(key, self.mode)
>>
>>IOError: [Errno 2] No such file or directory: '/home/mmokrejs/public_html/IRES2/index.py'
>>
>>
>>But, when I create .htaccess with:
>>
>>AddHandler mod_python .py
>>PythonHandler mod_python.publisher
>>PythonInterpPerDirectory On
>>PythonDebug On
>>
>>it works.
>>
>>index.py really doesn't exist. I get rid of this stupid error when .htaccess
>>contains only:
>>
>><IfModule mod_dir.c>
>>    DirectoryIndex IRESite_web.py
>></IfModule>
>>
>>
>>
>>
>>But then it complains about another module on line 1 in the source file:
>>
>>Mod_python error: "PythonHandler mod_python.publisher"
>>
>>Traceback (most recent call last):
>>
>>  File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 299, in HandlerDispatch
>>    result = object(req)
>>
>>  File "/usr/lib/python2.4/site-packages/mod_python/publisher.py", line 187, in handler
>>    module = page_cache[req]
>>
>>  File "/usr/lib/python2.4/site-packages/mod_python/cache.py", line 77, in __getitem__
>>    return self._checkitem(name)[2]
>>
>>  File "/usr/lib/python2.4/site-packages/mod_python/cache.py", line 119, in _checkitem
>>    value = self.build(key, name, opened, entry)
>>
>>  File "/usr/lib/python2.4/site-packages/mod_python/publisher.py", line 77, in build
>>    return ModuleCache.build(self, key, req, opened, entry)
>>
>>  File "/usr/lib/python2.4/site-packages/mod_python/cache.py", line 369, in build
>>    exec opened in module.__dict__
>>
>>  File "/home/mmokrejs/public_html/IRES2/IRESite_web.py", line 1, in ?
>>    import web_settings
>>
>>ImportError: No module named web_settings
>>
>>
>>
>>
>>
>>The errors changed, however from 
>>IOError: [Errno 2] No such file or directory: '/home/mmokrejs/public_html/IRES2/index.py'
>>to
>>ImportError: No module named web_settings
>>
>>
>>Why does it happen? I use at the moment http://cvs.apache.org/snapshots/mod_python/mod_python_20050704111017.tar.gz
>>under apache-2.0.54.
>>
>>
>>Martin
>>_______________________________________________
>>Mod_python mailing list
>>Mod_python at modpython.org
>>http://mailman.modpython.org/mailman/listinfo/mod_python
>>

-- 
Martin Mokrejs
Email: 'bW9rcmVqc21Acmlib3NvbWUubmF0dXIuY3VuaS5jeg==\n'.decode('base64')
GPG key is at http://www.natur.cuni.cz/~mmokrejs


More information about the Mod_python mailing list