Python Setup

If you've been following along with the IO Basics: Python guides, we are not using Adafruit Blinka for this specific tutorial. Blinka doesn't have a special timing module called pulseio (yet!). 

Instead, we are going to use the Adafruit Python DHT Sensor Library and the Adafruit IO Python Client Library.

The latest Raspbian (currently this is `Stretch`) is required for the installation of Adafruit IO + Blinka.

Update your Pi and Python

We'll assume you've already gotten your Raspberry Pi up and running and can log into the command line.

Go ahead and ssh into your Raspberry Pi via terminal or a ssh client:

ssh [email protected]

Run the standard updates:

sudo apt-get update

sudo apt-get upgrade

and

sudo pip3 install --upgrade setuptools

Make sure you're using Python 3!

The default python on your computer may not be python 3. Python 2 is officially discontinued and all our libraries are Python 3 only.

We'll be using python3 and pip3 in our commands, use those versions of python and pip to make sure you're using 3 and not 2

Installing Adafruit Python DHT Library

We're ready to install the Adafruit Python DHT Library. This library will allow our Raspberry Pi to read the temperature and humidity values from the DHT22. We'll use pip to install the library from PyPi. 

Enter the following in your terminal to install the Adafruit Python DHT Library:

sudo pip3 install Adafruit_DHT

Installing Adafruit IO Python Library

We'll also need to install the Adafruit IO Python Client Library to communicate with Adafruit IO.

Run the following command to install the Adafruit IO Client for Python:

pip3 install adafruit-io

If the installation gives you 'insufficient permissions' errors, add 'sudo' before the call to pip3

Downloading Example Code

The example code is contained within the Adafruit IO Python Client's examples/basics subdirectory.

Navigate to the root directory of the Pi by entering the following in the terminal:

cd ~

Download the latest version of the Adafruit IO Python Client's GitHub repository by running

git clone https://github.com/adafruit/io-client-python.git

Navigate to the folder's example code for the examples

cd io-client-python/examples/basics/

This guide was first published on Feb 20, 2017. It was last updated on Feb 20, 2017. This page (Python Setup) was last updated on May 25, 2019.