<< return to Pixycam.com

Pixy2: Python3 Linux

Hello,

I am a college student that will be using pixy cam for my project. My only problem is that I need Pixy2 to work with Python3 API. Just to start it, I installed libpixyusb2 and tried the CPP examples which worked. But when I tried doing the Python API and run it with ($ python3) and it’s giving me this error:

Input: $ python3 get_blocks_python_demo.py

Output:

  File "get_blocks_python_demo.py", line 2, in <module>
    import pixy
  File "/home/ubuntu/pixy2/build/python_demos/pixy.py", line 15, in <module>
    import _pixy
  ModuleNotFoundError: No module named '_pixy'

I already tried this forum: https://forum.pixycam.com/t/libpixyusb-python-module-trouble-python-3-related/6453/8
He basically said to change the Python —> Python3 in the bash file of build_python_demos.sh. But it didn’t work for me, the error is still the same as the top.

Please help…

Hello,
You need to change your system python to point to python3. That is, for example:

pi@alpha:~/$ which python
/usr/bin/python
pi@alpha:~/$ ls -l /usr/bin/python
lrwxrwxrwx 1 root root 18 Jul 25 22:12 /usr/bin/python -> /usr/bin/python3.7

Here, the system python points to python3 (python3.7 specifically)
You may need to replace the link for python if it’s pointing to a python 2 version.

Once you get it pointing to the correct version, you can try to bulld.

Hope this helps.

Edward

Hello,
Thank you so much for the quick reply. I apologize for not mentioning that I only have python3 installed on my system. Is it really possible to run the demo python script with python3?

I did what you told me but unfortunately it didnt work :

ubuntu@ubuntu:~$ which python
/usr/bin/python
ubuntu@ubuntu:~$ ls -l /usr/bin/python
lrwxrwxrwx 1 root root 7 Apr 15  2020 /usr/bin/python -> python3

Also when I try to run the build_python_demos.sh file, it gives me this error output:

Update: So I got it working by installing python3-dev to have an additional library and editing the file of build_python_demos.sh(python --> python3). But now the only problem I have is that when I run the file without sudo, I get this output:

ubuntu@ubuntu:~/pixy2/build/python_demos$ python3 get_blocks_python_demo.py
Pixy2 Python SWIG Example -- Get Blocks
Segmentation fault (core dumped)

However, w/ sudo, it works well. My question is, can I run the script without adding sudo? I am actually trying to implement pixy to ROS and to do that I need to run the script without sudo and avoid “Segmentation fault”

If there is any solution, I will really appreciate it. Thanks in advance

Hello,
Pixy permissions are usually an issue with udev rules. Hopefully this helps:

https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:installing_pixymon_on_linux#add-permissions-for-pixy-usb-interface

Edward

1 Like

Thank you so much! the link you sent me worked. I really appreciate the fast response, have a good one!