<< return to Pixycam.com

Python RGB Demo Not Working

Hello all, I am using a RPI 4 and am utilizing Thonny Python compiler to execute all my codes. I currently have gone through all the procedures in the wiki link that the Pixy2 Camera currently has to troubleshoot and etc. I can get the code to compile in the linux command window, but I can not use Pixymon at the same time. I must just see the code run and see nothing throughout the Pixymon window. This I don’t really care about.

What I am most desperate to find the solution to is all the errors that I keep getting when running hte RGB Demo Script in Python. Currently I receive these errors:

Python 3.7.3 (/usr/bin/python3)

%Run get_rgb_demo.py
Traceback (most recent call last):
File “/home/pi/pixy2/build/python_demos/pixy.py”, line 14, in swig_import_helper
return importlib.import_module(mname)
File “/usr/lib/python3.7/importlib/init.py”, line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1006, in _gcd_import
File “”, line 983, in _find_and_load
File “”, line 967, in _find_and_load_unlocked
File “”, line 670, in _load_unlocked
File “”, line 583, in module_from_spec
File “”, line 1043, in create_module
File “”, line 219, in _call_with_frames_removed
ImportError: /home/pi/pixy2/build/python_demos/_pixy.so: undefined symbol: PyInstance_Type

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/pi/pixy2/build/python_demos/get_rgb_demo.py”, line 2, in
import pixy
File “/home/pi/pixy2/build/python_demos/pixy.py”, line 17, in
_pixy = swig_import_helper()
File “/home/pi/pixy2/build/python_demos/pixy.py”, line 16, in swig_import_helper
return importlib.import_module(’_pixy’)
File “/usr/lib/python3.7/importlib/init.py”, line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: /home/pi/pixy2/build/python_demos/_pixy.so: undefined symbol: PyInstance_Type

I know I’m dealing with a later version of Python and I plan to change it to 3 or 2 because of what was mentioned in the wiki link but I would love to be able to manipulate this file for my senior design project. Any help would be greatly appreciated. Thank you

Hello,
The Python support uses libpixyusb2. Go into the scripts directory (at the root of the repository) and run “build_all.sh” to make sure that everything is built and then try to run the Python demos.

Edward

I have the same issue (Python 3.7.3), but have figured out that the script can be run when using the sudo command in the terminal. However, I cannot use any script from build/python_demos in an IDE (I am using Thonny on a Raspberry Pi 4).

How can I run this inside Thonny?

I figured out that the PixyMon for linux tutorial has the answer.

2.2.3. Add permissions for Pixy USB interface

In order to communicate with Pixy over USB as a non-root user you must set permissions for Pixy.

To do this copy the ‘pixy.rules’ file to ‘/etc/udev/rules.d’

In the terminal window type:

cd ../src/host/linux/ <— this is while inside of the pixy2 folder
sudo cp pixy.rules /etc/udev/rules.d/ <— this copies the pixy.rules file into the udev folder (granting permissions)

1 Like

Thanks for the good suggestion Stew!