python3.5.9源码安装ssl路径问题
问题来源:安装好的python3使用pip3 install 会报Can't connect to HTTPS URL because the SSL module is not available
问题分析:查找网上的解答后会发现是python编译的时候没有设置ssl
,有解决方案是在./configure --with-ssl,然而其实根本没有这个参数
问题解决:
首先安装ssl这个在很多教程中都有,建议源码安装
然后找到ssl的include和lib路径,一般在/usr/local/include和/usr/local/lib
-
然后修改python安装包下的setup.py中 :
/usr/local/ssl/include ----> /usr/local/include
/usr/local/ssl/lib ----> /usr/local/lib
修改后如下:# Detect SSL support for the socket module (via _ssl) search_for_ssl_incs_in = [ '/usr/local/include', '/usr/contrib/ssl/include/' ] ssl_incs = find_file('openssl/ssl.h', inc_dirs, search_for_ssl_incs_in ) if ssl_incs is not None: krb5_h = find_file('krb5.h', inc_dirs, ['/usr/kerberos/include']) if krb5_h: ssl_incs += krb5_h ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs, ['/usr/local/lib', '/usr/contrib/ssl/lib/' ] )
然后再执行
./configure
make -j$(pronc)
make test -j$(pronc)
sudo make install
- 最后查看是否安装完成
python3
import ssl