如何在编译Python指定使用自定义安装的openssl

安装Openssl源码包


#wget https://www.openssl.org/source/openssl-1.0.2g.tar.gz | tar xz && cd openssl-1.0.2g && ./config shared --prefix=/usr/local/python2.7 && make && make install

安装python2.7.13源码包


#export LDFLAGS="-L/usr/local/python2.7/lib/"
#export LD_LIBRARY_PATH="/usr/local/python2.7/lib/"
#export CPPFLAGS="-I/usr/local/python2.7/include -I/usr/local/python2.7/include/openssl"
#wget https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz| tar -xzf Python-2.7.13.tgz && cd Python-2.7.13 
#./configure --prefix=/usr/local/python2.7
#make
#make altinstall 
#ln -s /usr/local/python2.7/bin/python /usr/local/bin/python
# python
Python 2.7.13 (default, May 21 2017, 05:15:16) 
[GCC 4.3.4 [gcc-4_3-branch revision 152973]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>> ssl.OPENSSL_VERSION
'OpenSSL 1.0.2g  1 Mar 2016'

这样SSL模块就导入了

你可能感兴趣的:(Python模块积累)