I wanted to execute a Python file via GUI. So I'm using following line to run that script. It's working fine on 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')
But when I'm trying on Linux it says run.py: not found. I can't figure out the issue. run.py is in the same directory as GUI.py.
martineau
124k29 gold badges181 silver badges319 bronze badges
asked Apr 21, 2021 at 7:55
Axen_Rangs
4273 gold badges9 silver badges25 bronze badges
1 Answer 1
You can try to do
os.system('./run.py')
or if that doesn't work then
os.system('python3 run.py') # or just python for python 2
Sign up to request clarification or add additional context in comments.
Comments
lang-py
run.pydirectly except its executable attributes are set and has propershebangat the first line of the file. Otherwise you need to usePythonto execute the script explicitly.