I am using offlineimap to fetch mail from several IMAP servers. This used to work but today offlineimap has been unable to fetch mail, producing the following errors:

*** Processing account example
 Establishing connection to imap.gmail.com:993
 ERROR: Unknown SSL protocol connecting to host 'imap.gmail.com' for
 repository '<redacted>'. OpenSSL responded:
 [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)
*** Finished account 'example' in 0:00

Relevant parts of my configuration are:

[Account example]
localrepository  =  local-example
remoterepository = remote-example

[Repository local-example]
type = Maildir
localfolders = ~/mail/example

[Repository remote-example]
maxconnections = 1
type = Gmail
remotehost = imap.gmail.com
remoteuser = example@gmail.com
remotepasseval = get_keychain_pass(account="example@sexpression.org.uk",
ssl = yes
sslcacertfile = /usr/local/etc/openssl/certs/dummycert.pem

The sslcacertfile configuration was created in response to this SO answer. The get_keychain_pass function is from this offlineimap configuation.

I am using offlineimap 6.5.7 built with Homebrew on OS X 10.10.4.


The problem started when I installed Homebrew's version of python rather than the Apple version. The error was resolved by running

brew uninstall python

I discovered this was the solution by reading about a similar error produced by another Python program on OS X.

  • this was correct for me too – v0d1ch Dec 30 '15 at 21:55

I have a need for both the Apple and Homebrew versions of Python installed. Some packages I need to install from pip, and I do not have administrative access to this work-issued Macbook Pro. Thus the only pip I have available to me is for Homebrew. What I ended up doing is set the following PYTHONPATH before launching the offlineimap.py script:

PYTHONPATH="/Library/Python/2.7/site-packages" exec "/Users/tblancher/homebrew/Cellar/offlineimap/7.0.7/libexec/offlineimap.py" "$@"

I also modified the offlineimap.py script itself. I changed the first line, from this:

#!/usr/bin/env python

To this:


Apparently env was picking up that it was in Homebrew, and therefore trying to use the Homebrew python. Offlineimap now works correctly, and so does my Homebrew-pip-installed Python package (mutt-ics, if you're curious).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.