1、安装ssl
apt-get install openssl
apt-get install libssl-dev
2、修改Moudles/Setup (该目录在python的解压目录下)
cd /root/Python-3.6.9/Modules # 这是我的目录
vi Setup
# 末行模式敲:/_socket 搜索,然后按照下面的解注释
# Socket module helper for socket(2)
_socket socketmodule.c timemodule.c
# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
#SSL=/usr/local/ssl
_ssl _ssl.c \
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL)/lib -lssl -lcrypto
3、重新安装一次python
./configure --prefix=/usr/local/python
make && make install
4、安装完成后发现导入ssl模块正常,不再报错
(ps:说实话,Ubuntu还是很恶心啊!!!)
参考:
https://blog.csdn.net/KunagisaTomo_i/article/details/81177558