问题
I've just installed Python 2.6.6 from sources and what I get:
>>> import hashlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.6/hashlib.py", line 136, in <module>
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
回答1:
Install openssl-dev
and rebuild.
回答2:
I have just tested this on my 2.6.6 installation and I have had no such problem. You might want to try reinstalling. Also, I am not sure if the hashlib module can be installed separately, but you may want to try that as well.
Also, can you try importing specific functions from hashlib and give the output?
>>> from hashlib import sha512
because if you don't need MD5's, you could avoid the problem.
回答3:
You should have a md5.so somewhere, if it's not on your python path, I think it could cause this problem. I've ran into this problem before.
Let me know if this helps.
来源:https://stackoverflow.com/questions/4200292/python-and-hashlib-module