md5 module error

eozzy picture eozzy · Jan 18, 2010 · Viewed 13.2k times · Source

I'm using an older version of PLY that uses the md5 module (among others):

import re, types, sys, cStringIO, md5, os.path

... although the script runs but not without this error:

DeprecationWarning: the md5 module is deprecated; use hashlib instead

How do I fix it so the error goes away?

Thanks

Answer

Dyno Fu picture Dyno Fu · Jan 18, 2010

I think the warning message is quite straightforward. You need to:

from hashlib import md5

or you can use python < 2.5, http://docs.python.org/library/md5.html