Python 和 hashlib 模块
我刚刚从源代码安装了 Python 2.6.6,我得到了什么:
>>> 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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
安装 openssl-dev 并重建。
Install
openssl-dev
and rebuild.我刚刚在我的 2.6.6 安装上测试过这个,没有遇到这样的问题。您可能想尝试重新安装。另外,我不确定 hashlib 模块是否可以单独安装,但您可能也想尝试一下。
另外,您可以尝试从 hashlib 导入特定函数并给出输出吗?
因为如果你不需要 MD5,你就可以避免这个问题。
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?
because if you don't need MD5's, you could avoid the problem.
你应该在某个地方有一个 md5.so ,如果它不在你的 python 路径上,我认为它可能会导致这个问题。我以前遇到过这个问题。
让我知道这是否有帮助。
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.