<< return to Pixycam.com

Trying to Install Python Library with setup.py



So I’ve been able to build and run all the pixy demos on a Raspberry Pi. I wanted to install the python library using the setup.py script in build/python_demos, but when I try to execute python setup.py install, I get an error:

dir =
running build
running build_py
running build_ext
building ‘_pixy’ extension
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-Ub3vap/python2.7-2.7.13=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/libusb-1.0 -I/usr/local/include/libusb-1.0 -I…/…/…/common/inc -I…/…/…/host/libpixyusb2/include/ -I…/…/…/host/arduino/libraries/Pixy2 -I/usr/include/python2.7 -c pixy_wrap.cxx -o build/temp.linux-armv7l-2.7/pixy_wrap.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
pixy_wrap.cxx:3134:18: fatal error: util.h: No such file or directory
#include “util.h”
compilation terminated.
error: command ‘arm-linux-gnueabihf-gcc’ failed with exit status 1

Not sure what is wrong here. Does anyone have any suggestions?


I added the path ~/GitHub/pixy2/build/python_demos to PYTHONPATH and can now import the library elsewhere, but why doesn’t setup.py work?


Hi Brettbalogh,
Good question – I’m forwarding to our python guy.




Which Linux distribution and version are you using? What type of Raspberry Pi is this?




The python libraries are built in the src/host/libpixyusb2_examples/python_demos folder. If you try to run setup.py it from the build/python_demos folder (which is where the output from the SWIG build is copied to), the include and source paths in setup.py will need to be modified because the include and source paths are relative in setup.py .

Here’s a setup.py that has been modifed to be run in the “build/python_demos” folder:

#!/usr/bin/env python

from distutils.core import setup, Extension

pixy_module = Extension('_pixy',
  include_dirs = ['/usr/include/libusb-1.0',
  libraries = ['pthread',
  sources =   ['pixy_wrap.cxx',

import os
print "dir = "
print os.path.dirname(os.path.realpath(__file__))

setup (name = 'pixy',
  version = '0.1',
  author = 'Charmed Labs, LLC',
  description = """libpixyusb2 module""",
  ext_modules = [pixy_module],
  py_modules = ["pixy"],