I am able to get my script to work when I manually run it in the Thonny IDE, but I cannot trigger it in the Terminal window with
sudo python /home/pi/myscript