Book Image

Getting Started with Python and Raspberry Pi (Redirected from Learning Python By Developing Raspberry Pi Applications)

By : Dan Nixon
Book Image

Getting Started with Python and Raspberry Pi (Redirected from Learning Python By Developing Raspberry Pi Applications)

By: Dan Nixon

Overview of this book

Table of Contents (18 chapters)
Getting Started with Python and Raspberry Pi
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Installing and testing the Python library


Now that we have the camera module installed and working, we can install and start using the picamera library.

  1. First, we need to install the pip package manager in order to install the latest version of the picamera library. This can be done using the following command:

    sudo apt-get install python-pip
    
  2. Next, we will update the installed version of the picamera library using the following command:

    sudo pip install --upgrade picamera
    

Now that the library is installed, we can test it out with a basic example to ensure that both the camera and the library are working correctly. This also gives us a chance to look at the basic usage of the picamera library.

We will do this from an interactive Python shell. First, we will import the required libraries:

import time
from picamera import PiCamera

Next, we will use the with statement to manage opening and closing the camera:

with PiCamera() as cam:

Now, we will set the resolution the camera will capture at and start...