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

平台 :ubuntu16.04
python:python3.6.9

  1. 今天在一台新计算云上部署脚本的时候,出现了这个报错

    AttributeError: module 'smtplib' has no attribute 'SMTP_SSL'
    
  2. 试过不少方法这里,这里只讲有用的,博主通过源码新装的python3.6,遇到问题应该是ssl导致的相关问题

  3. 确保已安装openssl

    apt install openssl 
    
  4. 进入源码目录修改Setup和Setup.dist,如图字段解除注释

     ```
     cd /root/Python-3.6.9/
     cd Modules/
     vim Setup
     vim Setup.dist
     ```
    

    解决python中module 'smtplib' has no attribute 'SMTP_SSL'报错问题_第1张图片

  5. 重新编译

    ./configure --prefix=/usr/local/python3.6
    
    make && make install
    
  6. 出现报错
    在这里插入图片描述

    sudo apt-get install libssl-dev  # 安装缺失文件
    
  7. 重新编译,大功告成

你可能感兴趣的:(Python,email)