简体   繁体   English

使用 Python 在 Raspberry Pi 上打开程序?

[英]Open Programms on Raspberry Pi using Python?

How can i open and close any programm on my raspberry pi using python?如何使用 python 打开和关闭树莓派上的任何程序?

I want to open florence.desktop (Virtual Keyboard) and close it.我想打开 florence.desktop(虚拟键盘)并关闭它。 I have tried it with:我已经尝试过:

P = subprocess.Popen(["/usr/share/applications/florence.desktop"] P = subprocess.Popen(["/usr/share/applications/florence.desktop"]

but the error message is:但错误信息是:

Traceback (most recent call last): File "/usr/lib/python3.7/tkinter/ init .py", line 1705, in call return self.func(*args) File "/home/pi/Desktop/Software_1.0.2/Software/Software/Hautpprogramm/Start_Seite.py", line 588, in Wartungs_Button = Button(root, text="Wartungsfunktion", font=bigFont, fg ="black", bg="#D3d3d3", command=lambda: newWindow_Wartung_PW()) File "/home/pi/Desktop/Software_1.0.2/Software/Software/Hautpprogramm/Start_Seite.py", line 165, in newWindow_Wartung_PW P = subprocess.Popen(["/usr/share/applications/florence.desktop"]) File "/usr/lib/python3.7/subprocess.py", line 775, in init restore_signals, start_new_session) File "/usr/lib/python3.7/subprocess.py", line 1522, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) PermissionError: [Errno 13] Permission denied: '/usr/share/applications/florence.desktop'回溯(最近通话最后一个):文件“/usr/lib/python3.7/tkinter/初始化的.py”,线1705,在调用返回self.func(*参数)文件“/家/ PI /桌面/ Software_1。 0.2/Software/Software/Hautpprogramm/Start_Seite.py”,第 588 行,在 Wartungs_Button = Button(root, text="Wartungsfunktion", font=bigFont, fg ="black", bg="#D3d3d3", command=lambda: newWindow_Wartung_PW()) 文件“/home/pi/Desktop/Software_1.0.2/Software/Software/Hautpprogramm/Start_Seite.py”,第 165 行,在 newWindow_Wartung_PW P = subprocess.Popen(["/usr/share/applications/florence. desktop"]) 文件“/usr/lib/python3.7/subprocess.py”,第 775 行,在init restore_signals,start_new_session 中)文件“/usr/lib/python3.7/subprocess.py”,第 1522 行,在 _execute_child引发 child_exception_type(errno_num, err_msg, err_filename) PermissionError: [Errno 13] 权限被拒绝: '/usr/share/applications/florence.desktop'

normally you should try to execute your script with sudo, but that wouldn't help here, because you're trying to run a .desktop file, that's not really a program.通常,您应该尝试使用 sudo 执行脚本,但这在这里无济于事,因为您正在尝试运行 .desktop 文件,这并不是真正的程序。 Try this: subprocess.Popen(["florence"])试试这个: subprocess.Popen(["florence"])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM