[英]Run Terminal Commands on Raspberry Startup
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我正在开发一个使用curses和pygame库的项目,我的python程序/脚本只能使用终端运行,否则会发生此错误
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我想使用这两个命令在 Raspberry pi 启动时运行我的程序
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)我知道 rc.local 但无法运行它....(首先打开终端,然后运行这 2 个命令以运行我的脚本)
Running on startup, eg, using rc.local
, there's at least two problems:在启动时运行,例如使用rc.local
,至少有两个问题:
TERM
environment variable is not set (giving the setupterm: could not find terminal
message)未设置TERM
环境变量(给出setupterm: could not find terminal
消息)I spent around 1 day and test 4 solutions for Linux/raspberry startup run script issues.我花了大约 1 天时间测试了 4 个针对 Linux/raspberry 启动运行脚本问题的解决方案。 Then here is the solution (I choose crontab)那么这里是解决方案(我选择crontab)
pi@ crontab -e pi@crontab -e
Then choose nano and edit like this... It is tricky, ı found after test may be more than 10x times:然后选择nano并像这样编辑......这很棘手,我在测试后发现可能超过10倍:
@reboot cd /home/pi/beetool && /usr/bin/python3 run.py &
My code is waiting for me under /home/pi/beetool.我的代码在 /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 ...所以我希望这也能帮助别人......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.