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.

martineau
124k29 gold badges181 silver badges319 bronze badges
asked Apr 21, 2021 at 7:55
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
answered Apr 21, 2021 at 7:59
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.