问题
I am working on a project in which I am using curses and pygame librarie, my python program/script can only be run through using terminal otherwise this error occurs
fd=_sys.__stdout__.fileno())
_curses.error: setupterm: could not find terminal
I want to run my program on startup of Raspberry pi by using these two commands
cd Desktop
python test.py
I am aware of rc.local but unable to run this....(first open terminal and then run these 2 commands in order to run my script)
回答1:
Running on startup, e.g., using rc.local
, there's at least two problems:
- the
TERM
environment variable is not set (giving thesetupterm: could not find terminal
message) - you won't be able to handle input, only output...
回答2:
I spent around 1 day and test 4 solutions for Linux/raspberry startup run script issues. Then here is the solution (I choose crontab)
- open crontab (use linux@crontab -e -> not use sudo crontab -e ... thats could be error in future some access for script etc.)
pi@ crontab -e
Then choose nano and edit like this... It is tricky, ı found after test may be more than 10x times:
@reboot cd /home/pi/beetool && /usr/bin/python3 run.py &
My code is waiting for me under /home/pi/beetool. If you don't change the directory that occurs error.
And my code uses infinite loop so I have to finish with "&" as you see above.
So I hope that helps someone, too ...
来源:https://stackoverflow.com/questions/52647466/run-terminal-commands-on-raspberry-startup