python - 通过 python linux 运行 python 脚本
问题描述
我想通过 GUI 执行一个 Python 文件。所以我正在使用以下行来运行该脚本。它在 Windows 上运行良好。
GButton_330=tk.Button(root)
GButton_330["bg"] = "#efefef"
ft = tkFont.Font(family='Times',size=10)
GButton_330["font"] = ft
GButton_330["fg"] = "#000000"
GButton_330["justify"] = "center"
GButton_330["text"] = "Start"
GButton_330.place(x=340,y=170,width=70,height=25)
GButton_330["command"] = lambda: os.system('run.py')
但是当我在 Linux 上尝试时,它会说run.py: not found
. 我无法弄清楚这个问题。run.py
与 位于同一目录中GUI.py
。
解决方案
你可以尝试做
os.system('./run.py')
或者如果那不起作用那么
os.system('python3 run.py') # or just python for python 2
推荐阅读
- java - 以编程方式检测其他应用程序上的内存泄漏?
- java - JWPlayer 无效的许可证密钥错误代码 (100012)
- angular - ViewChild('inputState', { 读取:MatAutocompleteTrigger})
- javascript - 我的键盘事件没有触发,我不知道为什么
- core-data - Swift UI - EnvironmentObject 更改不会更新 UI
- java - 使用两个线程时如何在每次更改后打印值
- python - Python按行写入csv
- c# - 使用 `function().Wait()` 调用异步函数有效,但 `async function()` 崩溃
- java - Spring data jdbc - 具体的join,具体的映射
- powershell - Powershell - 登录/注销事件 - Get-WinEvent 与 Get-EventLog