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
6
  • 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? Commented Nov 17, 2010 at 0:05
  • @inspectorG4dget: it has been installed 10 minutes ago. The same in the python 2.6 and 2.7 Commented Nov 17, 2010 at 0: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. Commented Nov 17, 2010 at 0:55
  • @Daniel Pryden: it is redhat Red Hat Enterprise Linux AS release 4 (Nahant Update 4) Commented Nov 17, 2010 at 1: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. Commented Nov 17, 2010 at 1:16

3 Answers 3

7

Install openssl-dev and rebuild.

Sign up to request clarification or add additional context in comments.

Comments

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.

1 Comment

it has been installed 10 minutes ago. I don't see any reason how reinstall could help
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.