PanTiltHat & Picamera in python


Hi, I am not a programmer basically. But having ideas on my specific applications: I have the pantilthat which I can control to certain positions. I have the Picamera as well, and I would like to take a snapshot once the pantilt has reached its new position. The problem: Where can I find “import PiCamera” in python code to take a snapshot or timelaps. And generally speaking in python code documentation revealing “import xxxx” where xxxx stands for time, RPi.GPIO as GPIO, PiCamera and so on where can I find it ?

Please guide me to approriate documentation.

Carl Blyh
Helsinki Finland


If I understand your question… for picamera specifically, you can source it as described here:

any other library, it depends on whether packages exists in the apt repo for the distribution you are using. Typically you would use something like:

sudo apt-get install python-xxxx python3-xxxx

the alternative is to source it from pypi using:

sudo pip install xxxx

… unfortunately, naming on pypi is not standardised or enforced by very strict policies, so xxxx might have no match, or might not be what you want and import xxxx subsequently may fail.

your best bet is to try the apt method, then, if you are unsure what the pypi package might be, search for xxxx and determine what in the returned list is the most adequate package.


incidentally, some module are built-in into python itself, such as time and there is nothing required to install them. It’s possible to consult (and familiarize yourself) with modules built-in the standard library by checking out something like:

(for Python 3.4 specifically in this case)

… one piece of advice I can give you is to install ipython:

sudo apt-get install ipython ipython3

then when you run ipython from the command line the enhanced interpreter that ipython provides will allow you to use autocompletion, so if you start typing say import picam the tab key should list all installed modules matching the pattern. This works for all built-in modules and installed 3rd party.