在启动时运行 python 脚本

编程入门 行业动态 更新时间:2024-10-27 08:39:59
本文介绍了在启动时运行 python 脚本 - debian的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用网络摄像头创建了一个应用程序.在这里,我的应用程序打开一个窗口来显示图像.我想在启动时运行该应用程序.如果我将启动文件放在 rc.local 中,它会在启动时成功运行但不允许显示窗口.它显示 -

I have created an application using webcam. here my application opens a window to display the image. I want to run that application on startup. if i put startup file in rc.local, it runs successfully at startup but not allowing to show window. it shows -

gtk warning cannot open display.

如何显示窗口?请大家帮帮我!!

how to show window? please help me guys!!

推荐答案

如果您运行的是 LXDE(raspbian 上的默认设置)

If you're running LXDE (default on raspbian)

将 .desktop 文件添加到您的 ~/.config/autostart 目录(如果不可用,请创建一个),其中包含 3 行内容:

Add a .desktop file to your ~/.config/autostart directory (create one if not available) with 3 lines saying :

[Desktop Entry] Type=Application Exec=python /path/to/your/application.py arguments

更新:更新了唐问题的评论

UPDATE: updated with Don Question's remark

更多推荐

在启动时运行 python 脚本

本文发布于:2023-11-05 06:23:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1560139.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:启动时   脚本   python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!