Python and hashlib module

让人想犯罪 __ 提交于 2019-12-23 10:53:23

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!