0

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.

2
  • Under Linux, you cannot exeute run.py directly except its executable attributes are set and has proper shebang at the first line of the file. Otherwise you need to use Python to execute the script explicitly. Commented Apr 21, 2021 at 8:18
  • Where's the "following line to run that script"? Commented Apr 21, 2021 at 8:28

1 Answer 1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.