13
votes

I have python 2.5.1 installed on my Ubuntu 10.04 x86_64 machine.

When i try to import hashlib/md5, the i get this error

>>> import hashlib 
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.5/hashlib.py", line 133, in <module>
md5 = __get_builtin_constructor('md5')
File "/usr/local/lib/python2.5/hashlib.py", line 60, in __get_builtin_constructor
import _md5
ImportError: No module named _md5

I have tried most of the solutions that I could find on google, but nothing works for me. Does anyone know how to solve this? Thank you!

1
Did you build this Python yourself, or does it come from apt-get? - Fred Foo
I downloaded the .tar file from the site and then ./configure, make and make install - Chaos
This is probably due to an incompatible OpenSSL libraries in your install that's causing the python to not build md5 (which is normally used) and not building _md5 (which is built if OpenSSL wasn't found). Is there a reason that you want to build your own rather than using ubuntu's? - wkl
@birryree I am facing the same issue. I don't have root privileges, so I can't update the openssl package. I donloaded its(libssl-dev) source code and compiled it. Now how can I make sure that if I build python, it uses this newly generated libraries and not the one's in system? - Rahul

1 Answers

7
votes

You have to have the package libssl-dev installed before configuring and compiling python from the tarball:

sudo apt-get install libssl-dev
cd YOUR_PYTHON_2.5_1_SRC_DIR
make clean
./configure
make
sudo make install

Do you have a good reason not to use the latest version in the 2.5.X series?