[Mailman-Users] ImportError: No module named _md5
Mark Sapiro
msapiro at value.net
Fri Nov 2 22:51:44 CET 2007
Helmut Schneider wrote:
>From: "Mark Sapiro" <msapiro at value.net>
>
>> Helmut Schneider wrote:
>>>I'm running mailman 2.1.9 chrooted. Recently FreeBSD switched from
>> Python2.4 to Python2.5 as default. As an effect mailman won't start
>> anymore using Python2.5:
>>>Traceback (most recent call last):
>>> File "/usr/local/mailman/bin/mailmanctl", line 107, in <module>
>>> from Mailman import Utils
>>> File "/usr/local/mailman/Mailman/Utils.py", line 32, in <module>
>>> import sha
>>> File "/usr/local/lib/python2.5/sha.py", line 6, in <module>
>>> from hashlib import sha1 as sha
>>> File "/usr/local/lib/python2.5/hashlib.py", line 133, in <module>
>>> md5 = __get_builtin_constructor('md5')
>>> File "/usr/local/lib/python2.5/hashlib.py", line 60, in
>>>__get_builtin_constructor
>>> import _md5
>>>ImportError: No module named _md5
>>>What did I miss? I suspect that some additional files need to be copied to
>>>the jail but which ones? Using Python2.4 mailman still works fine.
>> I had a similar if not the identical problem when I upgraded from
>> python 2.4 to 2.5 on a test system under cygwin (no chroot).
>> It turned out that Python 2.4 had been installed with prefix = /usr
>> (library in /usr/lib/python2.4) and Python 2.5 was installed with
>> prefix = /usr/local (library in /usr/local/lib/python2.5).
>> I think I could have fixed it with a few symlinks, but I wound up
>> removing and reinstalling python 2.5 with prefix = /usr.
>> Perhaps this will help you figure out what you need to do.
>
>It helped, yes, but I don't know how to solve it :)
Is it the case that the python2.4 libraries and the python2.5 libraries
are in different directories (e.g. /usr/lib vs. /usr/local/lib)?
>When I start mailman non-chrooted python requests md5.py while when chrooted
>it tries to access _md5.py. That only happens with md5, e.g. sha1 is not
>effected.
Except it's the import of sha1 that triggers it
Actually it's quite complicated. _md5 is a compiled C language version
of a module that also has a Python version.
What is going on is seen in your traceback:
>>> File "/usr/local/mailman/Mailman/Utils.py", line 32, in <module>
>>> import sha
>>> File "/usr/local/lib/python2.5/sha.py", line 6, in <module>
>>> from hashlib import sha1 as sha
>>> File "/usr/local/lib/python2.5/hashlib.py", line 133, in <module>
>>> md5 = __get_builtin_constructor('md5')
At this point, hashlib.py tries an import of the compiled C _hashlib.
It should succeed because it was built, but it fails
Hashlib.py then attempts to build a constructor using the _md5 builtin
which doesn't exist.
>>> File "/usr/local/lib/python2.5/hashlib.py", line 60, in
>>>__get_builtin_constructor
>>> import _md5
>>>ImportError: No module named _md5
The problem is if _hashlib doesn't exist then _md5 should and vice
versa. Either lib/python2.5/lib-dynload/_hashlib.so should exist or
lib/python2.5/lib-dynload/md5module.so should exist.
I think this problem arises when python 2.4 and python 2.5 coexist on
the system and one has _hashlib.so and the other has md5module.so.
Also, in my case it seemed to be corrected if both the python2.5 and
python2.5 libraries were in the same directory.
If it is the case that /path/to/lib/python2.4/lib-dynload/ has
md5module.so and not _hashlib.so and
/usr/local/lib/python2.5/lib-dynload/ has _hashlib.so and not
md5module.so, you could try creating a symlink (or a hard link) named
_hashlib.so in /path/to/lib/python2.4/lib-dynload/ to
/usr/local/lib/python2.5/lib-dynload/_hashlib.so and a symlink (or
hard link) named md5module.so in /usr/local/lib/python2.5/lib-dynload/
to /path/to/lib/python2.4/lib-dynload/md5module.so.
Or, maybe it's the other way around.
I don't know if this will fix it or not.
In my case, I had Python 2.4 installed in /usr, and I installed Python
2.5 in /usr/local and I wound up fixing the problem by reinstalling
Python 2.5 in /usr
--
Mark Sapiro <msapiro at value.net> The highway is for gamblers,
San Francisco Bay Area, California better use your sense - B. Dylan
More information about the Mailman-Users
mailing list