0
votes

i downloaded python2.6 and installed it on Solaris10 operating system which ships with python2.4 already installed however when tried importing the md5 module i was getting this error

 import md5
__main__:1: DeprecationWarning: the md5 module is deprecated; use hashlib instead
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/lib/python2.6/md5.py", line 10, in 
    from hashlib import md5
  File "/usr/local/lib/python2.6/hashlib.py", line 136, in 
    md5 = __get_builtin_constructor('md5')
  File "/usr/local/lib/python2.6/hashlib.py", line 63, in __get_builtin_constructor
    import _md5
ImportError: No module named _md5

PYTHONPATH=/usr/local/lib/python2.6

1

1 Answers

2
votes

See http://docs.python.org/library/md5.html:

Deprecated since version 2.5: Use the hashlib module instead.

Not much changes for you - you should import the haslib module and call hashlib.md5() instead of md5.new().

Edit: Then again, I just verified that module md5 normally imports correctly in Python 2.6 despite showing a warning. It will simply fall back to loading hashlib which apparently happened in your case as well. hashlib then imports module _md5 and if I understand correctly this one is compiled into Python. I guess your Python is compiled without MD5 support then?