FW: [mod_python] mod_python, python_handler error "Can't get/create interpreter"

Sean Glover seanglover at sympatico.ca
Tue Apr 24 20:00:34 EDT 2007


Looks like 'hashlib' and '_hashlib' alike are installed ok.

Python 2.5 (r25:51908, Apr  9 2007, 20:22:40)
[GCC 3.4.4 [FreeBSD] 20050518] on freebsd6
Type "help", "copyright", "credits" or "license" for more information.
>>> import _hashlib
>>> import hashlib
>>> dir(_hashlib)
['__doc__', '__file__', '__name__', 'new', 'openssl_md5', 'openssl_sha1',
'opens
sl_sha224', 'openssl_sha256', 'openssl_sha384', 'openssl_sha512']

Btw, appreciating the help so far! =)

-----Original Message-----
From: Graham Dumpleton [mailto:graham.dumpleton at gmail.com] 
Sent: Monday, April 23, 2007 8:53 PM
To: Sean Glover
Cc: mod_python at modpython.org
Subject: Re: [mod_python] mod_python, python_handler error "Can't get/create
interpreter"

On 24/04/07, Sean Glover <seanglover at sympatico.ca> wrote:
> Graham,
>
> I removed the line from my httpd.conf that loaded the php5 module and
> restarted:
>
> #LoadModule php5_module        libexec/apache22/libphp5.so
>
> Unfortunately, I still get the same error message.
>
> I loaded the 'md5' library in the python 2.5 terminal successfully, but
was
> unable to load '_md5'.
>
> Python 2.5 (r25:51908, Apr  9 2007, 20:22:40)
> [GCC 3.4.4 [FreeBSD] 20050518] on freebsd6
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import md5
> >>> import _md5
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> ImportError: No module named _md5

Hmmm, next time I should read the error messages properly. Problem is
that new Python 2.5 'hashlib' module is the one that is loading '_md5'
module. The 'hashlib' module being required by 'urllib2'.

The thing is that 'hashlib' shouldn't be trying to import '_md5' if
the '_hashlib' module imports okay from 'hashlib', which is what it
should use these days instead of '_md5'.

What do you get if you try importing '_hashlib' from command line
Python. If that doesn't work then your Python installed is borked in
some way and you will need to work out how to get 'hashlib' module to
import successfully from command line Python before you can get any
further.

Note that if 'hashlib' does import okay from command line, the problem
may be that '_hashlib' has shared library dependencies that can't be
resolved when imported under Apache. In that case you will need to
run:

  ldd _hashlib.so

from Python library directory and work out what libraries it uses and
where they are. If they are in a non standard location then you may
have to set directory in LD_LIBRARY_PATH for Apache to tell it where
they are. Ideally Python would be rebuilt while setting LD_RUN_PATH in
environment with that non standard library location so that directory
gets embedded in '_hashlib.so'.

Hopefully that makes half sense. :-)

Graham

> Error:
>
> [Mon Apr 23 20:21:28 2007] [error] make_obcallback: could not call init.\n
> Traceback (most recent call last):
>   File "/usr/local/lib/python2.5/site-packages/mod_python/apache.py", line
> 937, in init
>     from mod_python import importer
>   File "/usr/local/lib/python2.5/site-packages/mod_python/importer.py",
line
> 24, in <module>
>     from mod_python import publisher
>   File "/usr/local/lib/python2.5/site-packages/mod_python/publisher.py",
> line 50, in <module>
>     from cache import ModuleCache, NOT_INITIALIZED
>   File "/usr/local/lib/python2.5/site-packages/mod_python/cache.py", line
> 27, in <module>
>     import urllib2
>   File "/usr/local/lib/python2.5/urllib2.py", line 88, in <module>
>     import hashlib
>   File "/usr/local/lib/python2.5/hashlib.py", line 104, in <module>
>     md5 = __get_builtin_constructor('md5')
>   File "/usr/local/lib/python2.5/hashlib.py", line 31, in
> __get_builtin_constructor
>     import _md5
> ImportError: No module named _md5
> [Mon Apr 23 20:21:28 2007] [error] get_interpreter: no interpreter
callback
> found.
> [Mon Apr 23 20:21:28 2007] [error] [client 76.64.190.137] python_handler:
> Can't get/create interpreter., referer: http://randonom.com/test/python/
>
> Sean
>
> -----Original Message-----
> From: Graham Dumpleton [mailto:graham.dumpleton at gmail.com]
> Sent: Monday, April 23, 2007 7:09 PM
> To: Sean Glover
> Cc: mod_python at modpython.org
> Subject: Re: [mod_python] mod_python, python_handler error "Can't
get/create
> interpreter"
>
> On 24/04/07, Sean Glover <seanglover at sympatico.ca> wrote:
> > [Mon Apr 23 18:52:47 2007] [error] make_obcallback: could not call
init.\n
> > Traceback (most recent call last):
> >   File "/usr/local/lib/python2.5/site-packages/mod_python/apache.py",
line
> > 937,in init
> >     from mod_python import importer
> >   File "/usr/local/lib/python2.5/site-packages/mod_python/importer.py",
> line
> > 24, in <module>
> >     from mod_python import publisher
> >   File "/usr/local/lib/python2.5/site-packages/mod_python/publisher.py",
> > line 50, in <module>
> >     from cache import ModuleCache, NOT_INITIALIZED
> >   File "/usr/local/lib/python2.5/site-packages/mod_python/cache.py",
line
> > 27, in <module>
> >     import urllib2
> >   File "/usr/local/lib/python2.5/urllib2.py", line 88, in <module>
> >     import hashlib
> >   File "/usr/local/lib/python2.5/hashlib.py", line 104, in <module>
> >     md5 = __get_builtin_constructor('md5')
> >   File "/usr/local/lib/python2.5/hashlib.py", line 31, in
> > __get_builtin_constructor
> >     import _md5
> > ImportError: No module named _md5
> > [Mon Apr 23 18:52:47 2007] [error] get_interpreter: no interpreter
> callback
> > found.
> > [Mon Apr 23 18:52:47 2007] [error] [client 76.64.190.137]
python_handler:
> > Can't get/create interpreter.
>
> And there be the real problem. Either that version of Python hasn't
> got the md5 module installed, or you are running PHP on the same
> server and it is loading the mhash.so PHP module which has shown in
> the past to conflict in bad ways with mod_python.
>
> Thus, check if from command line Python you can import 'md5' module.
> If that works, disable PHP on web server and see if problem goes away.
> If it does, work out how to disable PHP mhash.so so it doesn't load.
>
> Graham
>
>
>
                                                  



More information about the Mod_python mailing list