Python Forum
Make a Python program executable in Windows - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Make a Python program executable in Windows (/thread-29920.html)



Make a Python program executable in Windows - Pedroski55 - Sep-25-2020

The gf now has Python on her Windows 10 laptop. She wants to learn a bit of Python.

To make the file executable in Linux I usually just go to the file, right click, choose Properties, then Permissions, then click the box "Allow executing the file as program" or I can use: chmod +x myscript.py. in bash. (Yesterday I spent about an hour wondering why my new app wouldn't run, until I realized I had forgotten this step!)

Then I can run the program in bash, or lately, I've made some tkinter stuff which starts from an icon on the desktop.

I know nothing about Windows, except that I don't like it.

How should I make a Python program executable in Windows?

I read a bit about pyinstaller. Is this the best way?


RE: Make a Python program executable in Windows - bowlofred - Sep-26-2020

Often the python installation will associate the ".py" extension with your python interpreter. So you just need to double-click on it in explorer. If you output text though, beware the window will disappear after the program exits. So if you want to see data you've print()ed at the end, you might end the program with something like:
input("Press enter to end the program")
so the window doesn't go away until you're done looking at the data. Wouldn't be a problem with tkinter where you normally exit explicitly.

You could also just type python <myprogram.py> from a command window.