Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
394 views
in Technique[技术] by (71.8m points)

python 2.7 - imapclient error on Windows

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 to c:Python27.

This works on Mac:

from imapclient import IMAPClient

IMAPClient("imap-mail.outlook.com", use_uid=True, ssl=(True))

But on Windows, if barfs like so:

Traceback (most recent call last):
  File "test_outlook_imap.py", line 3, in <module>
    IMAPClient("imap-mail.outlook.com", use_uid=True, ssl=(True))
  File "C:Python27libsite-packagesimapclientimapclient.py", line 152, in     __init__
    self._imap = self._create_IMAP4()
  File "C:Python27libsite-packagesimapclientimapclient.py", line 164, in _create_IMAP4
    self._timeout)
  File "C:Python27libsite-packagesimapclientls.py", line 153, in __init__
    imaplib.IMAP4.__init__(self, host, port)
  File "C:Python27libimaplib.py", line 173, in __init__
    self.open(host, port)
  File "C:Python27libsite-packagesimapclientls.py", line 159, in open
    self.sock = wrap_socket(sock, self.ssl_context, host)
  File "C:Python27libsite-packagesimapclientls.py", line 126, in wrap_socket
    ssl_context = create_default_context()
  File "C:Python27libsite-packagesimapclientls.py", line 109, in     create_default_context
    context.load_verify_locations(cadata=certs)
  File "C:Python27libsite-packagesackportssslcore.py", line 654, in     load_verify_locations
    self._ctx.load_verify_locations(cafile, capath)
  File "C:Python27libsite-packagesOpenSSLSSL.py", line 528, in load_verify_locations
    _raise_current_error()
  File "C:Python27libsite-packagesOpenSSL\_util.py", line 48, in     exception_from_error_queue
    raise exception_type(errors)
OpenSSL.SSL.Error: []

Is this to do with Window's handling of certificate chains?

Incidentally, it does the same for imap.gmail.com in the place of the Outlook domain.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This is not a final answer, but the work around that I've found is to uninstall imapclient and install an older version. Version 0.13 (and 0.11) worked for me, however after upgrading to 1.0.1 I got the same error message that you posted.

To uninstall imapclient with pip, run:

pip uninstall imapclient

To install the older 0.13 version with pip, run:

pip install imapclient==0.13

To verify the version of imapclient, from the interactive shell run:

>>> import imapclient >>> imapclient.__version__


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...