5

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
zerkms
  • 249,484
  • 69
  • 436
  • 539
  • Are you sure you have all the updates for this python version? Perhaps you're using something that's deprecated. I tried import hashlib. dir(hashlib._md5). with negative results. Try re-installing? – inspectorG4dget Nov 17 '10 at 00:05
  • @inspectorG4dget: it has been installed 10 minutes ago. The same in the python 2.6 and 2.7 – zerkms Nov 17 '10 at 00:08
  • What platform are you compiling for and/or on? I've found that when doing a cross-compile, hashlib is the most likely thing to break. – Daniel Pryden Nov 17 '10 at 00:55
  • @Daniel Pryden: it is redhat `Red Hat Enterprise Linux AS release 4 (Nahant Update 4)` – zerkms Nov 17 '10 at 01:11
  • What happens if you just do `import md5`? You should get a deprecation warning, not an error. If you get an error, you've greater issues with the install. – Nathan Ernst Nov 17 '10 at 01:16
  • @Nathan Ernst: yes, I have deprecation warning + stack trace about not found _md5 module. – zerkms Nov 17 '10 at 01:18

3 Answers3

7

Install openssl-dev and rebuild.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
0

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.

AJ00200
  • 16,327
  • 7
  • 23
  • 21
0

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.

Auston
  • 480
  • 1
  • 6
  • 13