In order for our Python code to work, we'll want to make sure a few libraries are installed.

First, from either the keyboard/monitor or SSH console type in:

sudo apt-get install python-pip

...you'll be asked if you want to continue. Type "Y" for yes, and hit enter.

This part will probably take a little while.

Then you can install the IMAPClient Python library, which lets Python talk to most e-mail services:

sudo pip install imapclient
Older versions of this guide used a Python module called feedparser to read an Atom feed from GMail.

The current version of the script should actually work with any e-mail provider that provides IMAP access. A few useful links:

If you have two-factor authentication enabled on your GMail account, you'll need to generate an application-specific password to use IMAP. I followed Google's detailed instructions and was up and running in no time.

Not sure if you have two-factor auth enabled? That probably means you don't, so don't worry about it for now.

This guide was first published on Jul 29, 2012. It was last updated on Mar 27, 2024.

This page (Prepare Python) was last updated on Jul 06, 2012.

Text editor powered by tinymce.