Prepare Python

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:

Download: file
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:

Download: file
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 Jul 29, 2012. This page (Prepare Python) was last updated on Feb 05, 2019.