Hy
I have several scripts that are execute after booting the sytem. How can I launch
a pixy script without sudo?
Andy
Hy
I have several scripts that are execute after booting the sytem. How can I launch
a pixy script without sudo?
Andy
Hello Andreas,
I’m not sure what your pixy script does. Can you describe?
Edward
for example the helo_pixy script. I can only run this with sudo.
It’s also described in the Wiki
@cd /pixy/build/hello_pixy
sudo ./hello_pixy@
Andy
Hi Andy,
Sorry, I was confused. The programs that use Pixy need to run as root because of the device permissions for Pixy. Setting device permissions varies between Linux versions. You can modify the “udev” rules on your system and see if that gives you non-root permission.
Hope this helps!
Jesse
thx jesse
I did now add the pixy folder to the visudo so that all user have permission to run any script without sudo.
andy
That’s another good solution. Thanks for sharing!
Edward
Could someone give a step-by-step for this? I have the same issue but don’t understand how to use visudo or udev.
I am running Raspbian 10, kernel 4.19.118-v71+.
Hey @stew - ok, bear with me here:
Open up a Terminal and enter:
sudo visudo
And enter your admin password at the prompt.
Use the arrow keys to scroll down to the third line (or thereabouts) - the one that looks something like:
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
You want to add the path to your folder containing the scripts you want to run. You would tack it on to the end of the line above like /snap/bin:/path/to/scripts/folder"
(In case you haven’t used Vi before: use the arrow keys to navigate to the spot you want to insert text, hit i
to drop into edit mode, enter your new text and then hit “esc” to get back to command mode. You can delete errant keystrokes from command mode by pressing “x” when the cursor is over the character you want to delete. When you’re ready to save, make sure you’re in command mode (hit “esc”) and then type :wq
and hit Enter. That will write changes, and quit.)
Phew! Hope this helps!
Cheers,
Jesse
Hi freed,
I followed these instructions and it did not change anything. My secure_path default looks like this:
secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/pi/Documents/AGV_Project/"
When I run the script (get_lines_python_demo.py) inside of the AGV_Project folder, I encounter the same importError I was previously receiving:
ImportError: /home/pi/Documents/AGV_Project/_pixy.so: undefined symbol: PyInstance_Type
The script oddly runs when I use sudo in front of it.
I have also tried running the C++ demos and cannot unless I run it as sudo. The error I receive for these demos is:
Connecting to Pixy2…Error
pixy.init() returned -1
OK, sorry for the confusion. This has been an issue with Python that I’ve long been confused about, and finally have some clarity on.
On Linux, when you preface a command with sudo
it basically runs it as another user (the superuser) and that user has a different $PATH variable. More info on this, in case you’re curious: https://superuser.com/questions/771500/sudo-vs-root-any-actual-differences/771523#771523
Try the instructions I gave above, but instead of running sudo visudo
(which will edit the superuser’s $PATH), try sudo env "PATH=$PATH" visudo
This should actually edit your user path.
Let me know if this solves the issue!
Cheers,
Jesse
If this doesn’t solve it, then I suspect a Python version issue related to the same sudo / regular user issue. I’m not sure how to fix it yet, but you can confirm by comparing the output of python --version
and sudo python --version