解决python中module ‘smtplib‘ has no attribute ‘SMTP_SSL‘报错问题

需要重新安装python

1. 下载python源码

https://www.python.org/ftp/python/3.6.8/Python-3.6.4.tar.xz

2. 安装 ssl 依赖

sudo apt-get install openssl

sudo apt-get install libssl-dev

否则会出现 ./Modules/_ssl.c:57:10: fatal error: openssl/rsa.h: No such file or directory

3. 解压源码 并进入源码目录 修改 Modules/Setup.dist 

#SSL=/usr/local/ssl
#_ssl _ssl.c \
# -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
# -L$(SSL)/lib -lssl -lcrypto

将ssl的下面4个注释去掉,修改后的结果为:

SSL=/usr/local/ssl
_ssl _ssl.c \
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL)/lib -lssl -lcrypto

4.然后再源码目录执行

make -j6 && make install

 

 

你可能感兴趣的:(Python基础)