Error importing hashlib with python 2.7 but not with 2.6 Error importing hashlib with python 2.7 but not with 2.6 python python

Error importing hashlib with python 2.7 but not with 2.6


The python2.7 package is dependent to the libssl1_0_0 package (openssl_1.0 runtime librairies).

I installed it, and added the /usr/local/ssl/lib directory in $LD_LIBRARY_PATH environnent variable.

And now it works perfectly! :)


same error for me. My case was a copied virtenv giving me this error on a new server. The default python was working.

I used

python2.7 -v -c "import hashlib" 2> output.txt

you should see something like this line below in your output.txt:

import hashlib # precompiled from hashlib.pycdlopen("/path/to/virtenv/lib/python2.7/lib-dynload/_hashlib.so", 2);ldd /path/to/virtenv/lib/python2.7/lib-dynload/_hashlib.so...   libssl.so.0.9.8 => not found   libcrypto.so.0.9.8 => not found...

So what I did is simply :

cp /usr/lib/python2.7/lib-dynload/_hashlib.so /*path-to-virtenv*/manager/lib/python2.7/lib-dynload/_hashlib.so


You can use below command and check which libraries are missing,

ldd /path/to/Python-Library/_hashlibmodule.so

e.g

ldd /usr/local/lib/python2.7/_hashlibmodule.so

If you get output like below, that means you are missing necessary openssl libraries

    linux-vdso.so.1 =>  (0x00007fffd6f6a000)    libssl.so.6 => not found    libcrypto.so.6 => not found    libpython2.7.so.1.0 => /lib64/libpython2.7.so.1.0 (0x00007ffb18b54000)    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007ffb18937000)    libc.so.6 => /lib64/libc.so.6 (0x00007ffb185a2000)    libdl.so.2 => /lib64/libdl.so.2 (0x00007ffb1839e000)    libutil.so.1 => /lib64/libutil.so.1 (0x00007ffb1819b000)    libm.so.6 => /lib64/libm.so.6 (0x00007ffb17f16000)    /lib64/ld-linux-x86-64.so.2 (0x0000003e0a000000)