我想在使用systemd重新启动时自动运行python文件。我尝试使用systemd的原因是因为我的python文件需要网络连接并在该时间点可用,并且/ home/pi目录需要准备好使用并且系统时间已由NTP更新继续。 但是我收到以下错误,当我尝试启动脚本:重启后使用systemd在raspbian上自动运行python文件
systemctl start mysript.service
无法启动myscript.service:单位myscript.service未能 负载:无效的参数。有关详细信息,请参阅系统日志和'systemctl状态 myscript.service'。
systemctl status myscript.service
myscript.service 加载:错误(原因:无效的参数) 有效无效(死)
myscript.service缺乏ExecStart设置。拒。
以下是myscript.service:
[unit]
Description=MyPythonFile
After=multi-user.target
[service]
Type=idle
ExecStart=/usr/bin/python3 /home/pi/mypythonfile/file.py
[Install]
WantedBy=multi-user.target
做任何人有任何想法,为什么我收到这个错误?
[编辑] 引用这篇文章:https://www.raspberrypi-spy.co.uk/2015/10/how-to-autorun-a-python-script-on-boot-using-systemd/
现在可以加载该服务,但是因为我的Python程序是用Tkinter我收到一个错误。
_tkinter.TclError: couldn't connect to display "0.0"
myscript.service: main process exited, code=exited, status=1/FAILURE
Unit myscript.service entered failed state.
我该如何解决这个错误?
编辑我的帖子有新错误,请帮忙! –
编辑我的答案 – Ben10
如果这没有帮助 - 看看这个:http://www.raspberry-projects。在“设置应用程序”下的com/pi/pi-operating-systems/raspbian/auto-running-programs-gui – Ben10