<< return to Pixycam.com

Libpixyusb python module trouble - python 3 related?


Hi there thanks for looking at this,

I am a beginner at python and having trouble using the libpixyusb module.

I followed the instructions to build the module on my mac, and was able to build and run the demos via the command line.

Now I am trying to include the module in another project, and I am not sure where the “module” is or what files it comprises.

I need to get all of the pixy module dependencies together because my application is a game, and I need to package all the dependencies along with the python interpreter in the game itself.

I have tried copying all of the files in the ‘python_demos’ folder into my game folder, and “import pixy” in the game python code doesn’t throw an error - but none of the pixy attributes are defined or usable. In short, I’m stuck and in over my head - I’d appreciate any advice or new avenues to try.

Thanks in advance.


Did you copy the ~/build/python_demos directory over? If those demos work from that directory, you should be able to copy them to different locations and run them. hmm…



Hi Edward, thank you for looking at this!

I copied the build/python_demos directory and I am able to run the demos in the new directory from the terminal python.

However even though all the python_demos directory content is being loaded by the game, and it is able to “import pixy” without an error or warning, trying to use anything from pixy in the game python causes attribute not defined errors.

The game’s python interpreter is python3.6 and it has a lib file to which I tried adding a new directory named “pixy” with the pixy demos contents, but that made no difference: “import pixy” doesn’t error but I can’t access the attributes. I have noticed that the other libraries mostly have an init file in them, but wasn’t sure if this was necessary in pixy’s case.


I believe you need to copy the pixy.i, pixy.py and swig.dat files over as well.



Hi Edward, thanks for the tips I tried them out - I discovered there was no swig.dat file at all so began thinking my build process was screwed up.

I have done an entirely fresh build from master, and I think the issue now is with python3.

python2 can run the examples fine, but python3 throws the following error:

Traceback (most recent call last):

File “get_rgb_demo.py”, line 2, in <module>

import pixy

File “/Users/me/Downloads/pixy2-master-2/build/python_demos/pixy.py”, line 15, in <module>

import _pixy

ImportError: dlopen(/Users/me/Downloads/pixy2-master-2/build/python_demos/_pixy.so, 2): Symbol not found: _PyClass_Type

Referenced from: /Users/me/Downloads/pixy2-master-2/build/python_demos/_pixy.so

Expected in: flat namespace

in /Users/me/Downloads/pixy2-master-2/build/python_demos/_pixy.so

I tried modifying the swig flag in build_python_demos.sh from -python to -py3 but it made no difference - it works as expected when running on python 2.7.


Does it work with Python3 when you run from the python_demos directory? Or are you saying Python3 doesn’t work when you copy over everything from the python_demos directory somewhere else?