컴파일 및 설치 파이썬 SSL 모듈을 호출 할 수 없습니다 후

우분투 소스 설치 Python3.6.5

문제 :

컴파일 요청 python3.6.5 우분투 설치 원본을 라이브러리를 사용하는 경우, 사이트 오류 SSL 모듈을 사용할 수없는 HTTPS를 방문

해결 방법 :

1. 제거 참고 모듈 / Setup.dist 코드 및 수정 파일 위치 SSL의 207-210 선

# 查看ssl文件位置
sudo openssl version -a
# 进入python3.6.5源码路径
cd /usr/bin/python3.6.5
# 修改setup.py文件
sido vim Modules/Setup.dist

# 修改结果如下:
# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
SSL=/usr/lib/ssl            # 你的ssl文件位置
_ssl _ssl.c \
        -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
        -L$(SSL)/lib -lssl -lcrypto

2. 수정하십시오 setup.py 파일

sudo vim setup.py

# 修改后结果如下 
# Detect SSL support for the socket module (via _ssl)
        search_for_ssl_incs_in = [
                              '/usr/local/ssl/include',
                              '/usr/contrib/ssl/include/openssl''
                             ]

3. 다시 컴파일 및 설치

sudo ./configure --enable-optimizations
sudo make -j 2
sudo make altinstall 

4. 테스트 기능

ubuntu@VM-0-14-ubuntu:~$ python
Python 3.6.5 (default, Oct 22 2019, 09:53:29)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>>
게시 59 개 원래 기사 · 원 찬양 19 ·은 10000 +를 볼

추천

출처blog.csdn.net/weixin_43507959/article/details/102691227