我已经成功地将GUI python应用程序作为服务运行在Raspberry pi中。使用的单位文件:
[Unit]
Description=Example systemd service.
After=graphical.target
[Service]
Type=simple
Environment="Display=:0"
Environment=XAUTHORITY=/home/pi/.Xauthority
WorkingDirectory=/home/pi/tf/
ExecStart=/home/pi/tf/myApp.py
Restart=always
RestartSec=10s
KillMode=process
Timeout=infinity
[Install]
WantedBy=graphical.target
在python应用程序的开头,我添加了路径python3,如下所示:
#! /address/where/is/python3
问题是我不能在Ubuntu中做同样的事情
我想是因为.Xauthority文件不存在。 我在ubuntu上运行
echo $XAUTHORITY
我得到:
/run/user/1000/Xauthority
然后我更改这些行:
Environment=XAUTHORITY=/run/user/1000/Xauthority
WorkingDirectory=/home/sergio/tf/
ExecStart=/home/sergio/tf/myApp.py
“journalctl-u myApp-f”显示以下错误:
cannot connect to X server
知道会是什么吗
我按照htorque在这篇文章中的步骤来解决这个问题https://askubuntu.com/questions/21923/how-do-i-create-the-xauthority-file
按照以下步骤操作:
现在我们在~/ 最后,服务文件myApp.service更新如下:
相关问题 更多 >
编程相关推荐