ImportError: No module named _md5
![](https://secure.gravatar.com/avatar/229d310df5dce28dbf7cce4032751417.jpg?s=120&d=mm&r=g)
Hi,
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.
Thanks, Helmut
![](https://secure.gravatar.com/avatar/746f7519ba02fb0d815e59f305c53fa2.jpg?s=120&d=mm&r=g)
Helmut Schneider wrote:
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.
-- Mark Sapiro <msapiro@value.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
![](https://secure.gravatar.com/avatar/229d310df5dce28dbf7cce4032751417.jpg?s=120&d=mm&r=g)
From: "Mark Sapiro" <msapiro@value.net>
It helped, yes, but I don't know how to solve it :)
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.
[root@BSDHelmut ~]# ktrace -id /usr/local/etc/rc.d/mailman start Site list is missing: mailman [root@BSDHelmut ~]# kdump -sf ./ktrace.out | grep md5 22569 python2.5 NAMI "/usr/local/mailman/Mailman/md5" 22569 python2.5 NAMI "/usr/local/mailman/Mailman/md5.so" 22569 python2.5 NAMI "/usr/local/mailman/Mailman/md5module.so" 22569 python2.5 NAMI "/usr/local/mailman/Mailman/md5.py" 22569 python2.5 NAMI "/usr/local/mailman/Mailman/md5.pyc" 22569 python2.5 NAMI "/usr/local/mailman/pythonlib/md5" 22569 python2.5 NAMI "/usr/local/mailman/pythonlib/md5.so" 22569 python2.5 NAMI "/usr/local/mailman/pythonlib/md5module.so" 22569 python2.5 NAMI "/usr/local/mailman/pythonlib/md5.py" 22569 python2.5 NAMI "/usr/local/mailman/pythonlib/md5.pyc" 22569 python2.5 NAMI "/usr/local/mailman/md5" 22569 python2.5 NAMI "/usr/local/mailman/md5.so" 22569 python2.5 NAMI "/usr/local/mailman/md5module.so" 22569 python2.5 NAMI "/usr/local/mailman/md5.py" 22569 python2.5 NAMI "/usr/local/mailman/md5.pyc" 22569 python2.5 NAMI "/usr/local/mailman/bin/md5" 22569 python2.5 NAMI "/usr/local/mailman/bin/md5.so" 22569 python2.5 NAMI "/usr/local/mailman/bin/md5module.so" 22569 python2.5 NAMI "/usr/local/mailman/bin/md5.py" 22569 python2.5 NAMI "/usr/local/mailman/bin/md5.pyc" 22569 python2.5 NAMI "/usr/local/lib/python2.5/md5" 22569 python2.5 NAMI "/usr/local/lib/python2.5/md5.so" 22569 python2.5 NAMI "/usr/local/lib/python2.5/md5module.so" 22569 python2.5 NAMI "/usr/local/lib/python2.5/md5.py" 22569 python2.5 NAMI "/usr/local/lib/python2.5/md5.pyc" [root@BSDHelmut ~]# ktrace -id /usr/local/etc/rc.d/mailman-chroot start 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 File "/usr/local/lib/python2.5/_md5.py", line 6, in <module> from hashlib import md5 ImportError: cannot import name md5 [root@BSDHelmut ~]# kdump -sf ./ktrace.out | grep md5 22576 python2.5 NAMI "/usr/local/mailman/pythonlib/_md5" 22576 python2.5 NAMI "/usr/local/mailman/pythonlib/_md5.so" 22576 python2.5 NAMI "/usr/local/mailman/pythonlib/_md5module.so" 22576 python2.5 NAMI "/usr/local/mailman/pythonlib/_md5.py" 22576 python2.5 NAMI "/usr/local/mailman/pythonlib/_md5.pyc" 22576 python2.5 NAMI "/usr/local/mailman/_md5" 22576 python2.5 NAMI "/usr/local/mailman/_md5.so" 22576 python2.5 NAMI "/usr/local/mailman/_md5module.so" 22576 python2.5 NAMI "/usr/local/mailman/_md5.py" 22576 python2.5 NAMI "/usr/local/mailman/_md5.pyc" 22576 python2.5 NAMI "/usr/local/mailman/bin/_md5" 22576 python2.5 NAMI "/usr/local/mailman/bin/_md5.so" 22576 python2.5 NAMI "/usr/local/mailman/bin/_md5module.so" 22576 python2.5 NAMI "/usr/local/mailman/bin/_md5.py" 22576 python2.5 NAMI "/usr/local/mailman/bin/_md5.pyc" 22576 python2.5 NAMI "/usr/local/lib/python2.5/_md5" 22576 python2.5 NAMI "/usr/local/lib/python2.5/_md5.so" 22576 python2.5 NAMI "/usr/local/lib/python2.5/_md5module.so" 22576 python2.5 NAMI "/usr/local/lib/python2.5/_md5.py" 22576 python2.5 NAMI "/usr/local/lib/python2.5/_md5.pyc" 22576 python2.5 NAMI "/usr/local/lib/python2.5/_md5.pyc" 22576 python2.5 NAMI "/usr/local/lib/python2.5/_md5.pyc" 22576 python2.5 NAMI "/usr/local/lib/python2.5/_md5.py" [root@BSDHelmut ~]#
![](https://secure.gravatar.com/avatar/746f7519ba02fb0d815e59f305c53fa2.jpg?s=120&d=mm&r=g)
Helmut Schneider wrote:
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)?
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:
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.
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@value.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
![](https://secure.gravatar.com/avatar/7bdecdef03708b218939094eb05e8b35.jpg?s=120&d=mm&r=g)
On 10/29/07, Helmut Schneider wrote:
I believe that Mailman 2.1.9 requires Python 2.4, preferably the latest release of Python 2.4. When they went to Python version 2.5, my understanding is that they broke some things that Mailman depends on.
I believe that Mailman 2.1.10 will probably be compatible with Python 2.5, but until then your only choice is to either downgrade the system to Python 2.4, or to install a second copy of Python 2.4 and rebuild Mailman to explicitly point to that alternative version.
-- Brad Knowles <brad@shub-internet.org> LinkedIn Profile: <http://tinyurl.com/y8kpxu>
![](https://secure.gravatar.com/avatar/746f7519ba02fb0d815e59f305c53fa2.jpg?s=120&d=mm&r=g)
Helmut Schneider wrote:
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.
-- Mark Sapiro <msapiro@value.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
![](https://secure.gravatar.com/avatar/229d310df5dce28dbf7cce4032751417.jpg?s=120&d=mm&r=g)
From: "Mark Sapiro" <msapiro@value.net>
It helped, yes, but I don't know how to solve it :)
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.
[root@BSDHelmut ~]# ktrace -id /usr/local/etc/rc.d/mailman start Site list is missing: mailman [root@BSDHelmut ~]# kdump -sf ./ktrace.out | grep md5 22569 python2.5 NAMI "/usr/local/mailman/Mailman/md5" 22569 python2.5 NAMI "/usr/local/mailman/Mailman/md5.so" 22569 python2.5 NAMI "/usr/local/mailman/Mailman/md5module.so" 22569 python2.5 NAMI "/usr/local/mailman/Mailman/md5.py" 22569 python2.5 NAMI "/usr/local/mailman/Mailman/md5.pyc" 22569 python2.5 NAMI "/usr/local/mailman/pythonlib/md5" 22569 python2.5 NAMI "/usr/local/mailman/pythonlib/md5.so" 22569 python2.5 NAMI "/usr/local/mailman/pythonlib/md5module.so" 22569 python2.5 NAMI "/usr/local/mailman/pythonlib/md5.py" 22569 python2.5 NAMI "/usr/local/mailman/pythonlib/md5.pyc" 22569 python2.5 NAMI "/usr/local/mailman/md5" 22569 python2.5 NAMI "/usr/local/mailman/md5.so" 22569 python2.5 NAMI "/usr/local/mailman/md5module.so" 22569 python2.5 NAMI "/usr/local/mailman/md5.py" 22569 python2.5 NAMI "/usr/local/mailman/md5.pyc" 22569 python2.5 NAMI "/usr/local/mailman/bin/md5" 22569 python2.5 NAMI "/usr/local/mailman/bin/md5.so" 22569 python2.5 NAMI "/usr/local/mailman/bin/md5module.so" 22569 python2.5 NAMI "/usr/local/mailman/bin/md5.py" 22569 python2.5 NAMI "/usr/local/mailman/bin/md5.pyc" 22569 python2.5 NAMI "/usr/local/lib/python2.5/md5" 22569 python2.5 NAMI "/usr/local/lib/python2.5/md5.so" 22569 python2.5 NAMI "/usr/local/lib/python2.5/md5module.so" 22569 python2.5 NAMI "/usr/local/lib/python2.5/md5.py" 22569 python2.5 NAMI "/usr/local/lib/python2.5/md5.pyc" [root@BSDHelmut ~]# ktrace -id /usr/local/etc/rc.d/mailman-chroot start 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 File "/usr/local/lib/python2.5/_md5.py", line 6, in <module> from hashlib import md5 ImportError: cannot import name md5 [root@BSDHelmut ~]# kdump -sf ./ktrace.out | grep md5 22576 python2.5 NAMI "/usr/local/mailman/pythonlib/_md5" 22576 python2.5 NAMI "/usr/local/mailman/pythonlib/_md5.so" 22576 python2.5 NAMI "/usr/local/mailman/pythonlib/_md5module.so" 22576 python2.5 NAMI "/usr/local/mailman/pythonlib/_md5.py" 22576 python2.5 NAMI "/usr/local/mailman/pythonlib/_md5.pyc" 22576 python2.5 NAMI "/usr/local/mailman/_md5" 22576 python2.5 NAMI "/usr/local/mailman/_md5.so" 22576 python2.5 NAMI "/usr/local/mailman/_md5module.so" 22576 python2.5 NAMI "/usr/local/mailman/_md5.py" 22576 python2.5 NAMI "/usr/local/mailman/_md5.pyc" 22576 python2.5 NAMI "/usr/local/mailman/bin/_md5" 22576 python2.5 NAMI "/usr/local/mailman/bin/_md5.so" 22576 python2.5 NAMI "/usr/local/mailman/bin/_md5module.so" 22576 python2.5 NAMI "/usr/local/mailman/bin/_md5.py" 22576 python2.5 NAMI "/usr/local/mailman/bin/_md5.pyc" 22576 python2.5 NAMI "/usr/local/lib/python2.5/_md5" 22576 python2.5 NAMI "/usr/local/lib/python2.5/_md5.so" 22576 python2.5 NAMI "/usr/local/lib/python2.5/_md5module.so" 22576 python2.5 NAMI "/usr/local/lib/python2.5/_md5.py" 22576 python2.5 NAMI "/usr/local/lib/python2.5/_md5.pyc" 22576 python2.5 NAMI "/usr/local/lib/python2.5/_md5.pyc" 22576 python2.5 NAMI "/usr/local/lib/python2.5/_md5.pyc" 22576 python2.5 NAMI "/usr/local/lib/python2.5/_md5.py" [root@BSDHelmut ~]#
![](https://secure.gravatar.com/avatar/746f7519ba02fb0d815e59f305c53fa2.jpg?s=120&d=mm&r=g)
Helmut Schneider wrote:
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)?
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:
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.
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@value.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
![](https://secure.gravatar.com/avatar/7bdecdef03708b218939094eb05e8b35.jpg?s=120&d=mm&r=g)
On 10/29/07, Helmut Schneider wrote:
I believe that Mailman 2.1.9 requires Python 2.4, preferably the latest release of Python 2.4. When they went to Python version 2.5, my understanding is that they broke some things that Mailman depends on.
I believe that Mailman 2.1.10 will probably be compatible with Python 2.5, but until then your only choice is to either downgrade the system to Python 2.4, or to install a second copy of Python 2.4 and rebuild Mailman to explicitly point to that alternative version.
-- Brad Knowles <brad@shub-internet.org> LinkedIn Profile: <http://tinyurl.com/y8kpxu>
participants (3)
-
Brad Knowles
-
Helmut Schneider
-
Mark Sapiro