PIP complains there is no ssl support in python

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting pip
Could not fetch URL https://pypi.python.org/simple/pip/: There was a problem confirming the ssl certificate: Can't connect to HTTPS URL because the SSL module is not available. — skipping
Could not find a version that satisfies the requirement pip (from versions: )
No matching distribution found for pip

Image for post
Image for post

Need to install openssl manualy:

wget openssl-1.0.2k.tar.gz
tar xvfz openssl-1.0.2k.tar.gz
./config
make && make install

then build python from source file, but met this problem:

building ‘_ssl’ extension
gcc -pthread -fPIC -fno-strict-aliasing -fPIC -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/ssl/include -I. -IInclude -I./Include -I/usr/local/include -I/root/Python-2.7.13/Include -I/root/Python-2.7.13 -c /root/Python-2.7.13/Modules/_ssl.c -o build/temp.linux-x86_64–2.7/root/Python-2.7.13/Modules/_ssl.o
/usr/bin/ld: /usr/local/ssl/lib/libssl.a(s3_meth.o): relocation R_X86_64_32 against `.rodata’ can not be used when making a shared object; recompile with -fPIC
/usr/local/ssl/lib/libssl.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
building ‘_hashlib’ extension
gcc -pthread -fPIC -fno-strict-aliasing -fPIC -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/ssl/include -I. -IInclude -I./Include -I/usr/local/include -I/root/Python-2.7.13/Include -I/root/Python-2.7.13 -c /root/Python-2.7.13/Modules/_hashopenssl.c -o build/temp.linux-x86_64–2.7/root/Python-2.7.13/Modules/_hashopenssl.o
/usr/bin/ld: /usr/local/ssl/lib/libcrypto.a(o_names.o): relocation R_X86_64_32 against `.text’ can not be used when making a shared object; recompile with -fPIC
/usr/local/ssl/lib/libcrypto.a: could not read symbols: Bad value

A shared libssl.so is required.
cd openssl-*/ && ./Configure shared
… then the shared libraries libssl.so**, libcrypto.so** are created.

cd /usr/local/src/openssl01.0.1c
./config — shared
make
make install
then export LD_LIBRARY_PATH=/usr/local/ssl/lib

before

# ldd /usr/local/ssl/bin/openssl
linux-vdso.so.1 => (0x00007ffcccb78000)
libdl.so.2 => /lib64/libdl.so.2 (0x00000033d8a00000)
libc.so.6 => /lib64/libc.so.6 (0x00000033d8e00000)
/lib64/ld-linux-x86–64.so.2 (0x00000033d8600000)

after:

ldd /usr/local/ssl/bin/openssl
linux-vdso.so.1 => (0x00007ffcea151000)
libssl.so.1.0.0 => /usr/local/ssl/lib/libssl.so.1.0.0 (0x00007f9339d0b000)
libcrypto.so.1.0.0 => /usr/local/ssl/lib/libcrypto.so.1.0.0 (0x00007f93398d4000)
libdl.so.2 => /lib64/libdl.so.2 (0x00000033d8a00000)
libc.so.6 => /lib64/libc.so.6 (0x00000033d8e00000)
/lib64/ld-linux-x86–64.so.2 (0x00000033d8600000)

make python will success

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store