Forums Niryo One Troubleshooting Starting Python Script on Startup Reply To: Starting Python Script on Startup

cducatez
Keymaster
Post count: 11

Hi,
1) If you want to do the “sudo” way, the problem is that in “sudo mode”, the linux user change to ‘root’ for the execution so it’s not the same environment as ‘Niryo’ user, so the “export PYTHONPATH…” isn’t changing the root user environment but the Niryo env’.
If you just set the PYTHONPATH temporary for each execution like this it should be fine:
sudo PYTHONPATH=${PYTHONPATH}:/home/niryo/catkin_ws/src/niryo_one_python_api/src/niryo_python_api python your_script.py

2) But for your case, it may be better to use the method described in the topics linked by S.Imura so your script is executed at the end of ROS loading and not after a “fixed” time of 1 minute

Best regards