imapclient error on Windows

前端 未结 2 1865
无人共我
无人共我 2020-12-18 05:08

Environment that I\'m having trouble on: Python 2.7.11 on Windows10 (patched up to date). Python installed via a msi. I\'ve checked PATH settings in settings, and it\'s set

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-18 05:24

    Here's a workaround that worked for me (Python 3.5, Windows 10), and which doesn't require downgrading:

    from backports import ssl
    from imapclient import IMAPClient
    
    context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
    
    server = IMAPClient('imap.gmail.com', ssl=True, ssl_context=context)
    

    The above code was derived from the developer's workaround here, but I found I only needed the one line defining context to make it work. Specifying other SSL/TLS protocols also worked.

提交回复
热议问题