[mod_python] _hashlib fails to load

Graham Dumpleton graham.dumpleton at gmail.com
Thu Apr 2 17:36:01 EDT 2009

2009/4/3  <Roselinda.Ackermans at ec.europa.eu>:
> Hi,
> I just installed mod_python module (3.3.1) from blastwave, on Solaris 9,
> with Apache 2 and python 2.5.1
> In httpd.conf :
> <Directory /www/test>
> AddHandler mod_python .py
> PythonHandler ptest
> PythonDebug On
> </Directory>
> ptest.py being a test script in /www/test
> When I try http://myserver/test/ptest.py, I get these errors in error_log :
> <...>
> File "/opt/csw/lib/python/hashlib.py", line 133, in <module>
> md5 = __get_builtin_constructor('md5')
> File "/opt/csw/lib/python/hashlib.py", line 60, in __get_builtin_constructor
> import _md5
> ImportError: No module named _md5
> [Mon Mar 23 15:27:29 2009] [error] get_interpreter: no interpreter callback
> foun
> d.
> [Mon Mar 23 15:27:29 2009] [error] [client] python_handler:
> Can't
> get/create interpreter.
> When I start python console, I can do "import hashlib" without error
> message.
> I put a few print statements around 'import _hashlib' in the hashlib.py
> file, and it seems indeed that 'import _hashlib' hits the exception when
> hashlib.py is loaded from within mod_python, but loads fine from within the
> python console.
> I also printed the value of sys.path, and this is the same in both cases.
> What could the problem then be ?

It shouldn't be trying to import _md5.so. That is a fallback attempt
when _hashlib.so cannot be loaded, but _md5.so isn't a part of Python
2.5 anymore.

Likely problem is that _hashlib.so cannot find the shared libraries it
is dependent upon.


  ldd /some/path/_hashlib.so

to work out what shared libraries it requires.

If you have added that library directory explicitly to LD_LIBRARY_PATH
in your environment to get command line Python to work, then you will
need to edit your Apache startup scripts, 'envvars' if you have a
standard Apache installation, to add:


So, post result of ldd and also do following and post results.

  >>> import hashlib


More information about the Mod_python mailing list