1. Installation¶
1.1. Raspbian installation¶
If you are using the Raspbian distro, you probably have picamera installed by default. You can find out simply by starting Python and trying to import picamera:
$ python -c "import picamera"
$ python3 -c "import picamera"
If you get no error, you’ve already got picamera installed! Just continue to Getting Started. If you don’t have picamera installed you’ll see something like the following:
$ python -c "import picamera"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named picamera
$ python3 -c "import picamera"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named 'picamera'
To install picamera on Raspbian, it is best to use the system’s package manager: apt. This will ensure that picamera is easy to keep up to date, and easy to remove should you wish to do so. It will also make picamera available for all users on the system. To install picamera using apt simply run:
$ sudo apt-get update
$ sudo apt-get install python-picamera python3-picamera
To upgrade your installation when new releases are made you can simply use apt’s normal upgrade procedure:
$ sudo apt-get update
$ sudo apt-get upgrade
If you ever need to remove your installation:
$ sudo apt-get remove python-picamera python3-picamera
1.2. Alternate distro installation¶
On distributions other than Raspbian, it is probably simplest to install system
wide using Python’s pip
tool:
$ sudo pip install picamera
If you wish to use the classes in the picamera.array
module then specify
the “array” option which will pull in numpy as a dependency:
$ sudo pip install "picamera[array]"
Warning
Be warned that older versions of pip will attempt to build numpy from source. This will take a very long time on a Pi (several hours on slower models). Modern versions of pip will download and install a pre-built numpy “wheel” instead which is much faster.
To upgrade your installation when new releases are made:
$ sudo pip install -U picamera
If you ever need to remove your installation:
$ sudo pip uninstall picamera
1.3. Firmware upgrades¶
The behaviour of the Pi’s camera module is dictated by the Pi’s firmware. Over
time, considerable work has gone into fixing bugs and extending the
functionality of the Pi’s camera module through new firmware releases. Whilst
the picamera library attempts to maintain backward compatibility with older Pi
firmwares, it is only tested against the latest firmware at the time of
release, and not all functionality may be available if you are running an older
firmware. As an example, the annotate_text
attribute relies
on a recent firmware; older firmwares lacked the functionality.
You can determine the revision of your current firmware with the following command:
$ uname -a
The firmware revision is the number after the #
:
Linux kermit 3.12.26+ #707 PREEMPT Sat Aug 30 17:39:19 BST 2014 armv6l GNU/Linux
/
/
firmware revision --+
On Raspbian, the standard upgrade procedure should keep your firmware up to date:
$ sudo apt-get update
$ sudo apt-get upgrade
Warning
Previously, these documents have suggested using the rpi-update
utility
to update the Pi’s firmware; this is now discouraged. If you have
previously used the rpi-update
utility to update your firmware, you can
switch back to using apt
to manage it with the following commands:
$ sudo apt-get update
$ sudo apt-get install --reinstall libraspberrypi0 libraspberrypi-{bin,dev,doc} z
> raspberrypi-bootloader
$ sudo rm /boot/.firmware_revision
You will need to reboot after doing so.
Note
Please note that the PiTFT screen (and similar GPIO-driven screens) requires a custom firmware for operation. This firmware lags behind the official firmware and at the time of writing lacks several features including long exposures and text overlays.