<< return to Pixycam.com

Pixy2 Using Python on a Raspberry Pi

I have recently gone through the demos in the documentation for running the python version of the code for my Pixy2 and all of the ones I’ve tried have worked.

Now I’m wanting to use the functions provided by the API to write my own program. I am running into an issue, however, in that I don’t know how to “Import” the module needed in my program. Would I set up my program in the pixy2/build/python_demos directory? Or would there be a way to import it into my code that is located elsewhere that I have become too tunnel-vision’d to notice? Any help would be appreciated.

(Raspberry Pi 4 Model B; Python 2.7)

EDIT: Made it work with the following addition:

import sys


import pixy
from ctypes import *
from pixy import *

Code works great now and I’m excited to get my robot working with it.

1 Like

Hooray! Glad you figured it out! Thanks so much for circling back to include your solution.

Let us know if you have other questions!