Python Forum
Make a Python program executable in Windows
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Make a Python program executable in Windows
#1
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?
Reply
#2
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to compile a Python script for a Windows / Linux executable? netanelst 2 1,279 May-24-2022, 07:02 AM
Last Post: netanelst
  Is it possible to make a program recognize how many clicks it has had on the monitor? jao 0 1,130 Feb-25-2022, 06:31 PM
Last Post: jao
  Python executable Script (Wrapper) Hwang 2 1,849 Jan-12-2022, 06:53 PM
Last Post: Hwang
  No module named '_cffi_backend' error with executable not with python script stephanh 2 5,559 Nov-25-2021, 06:52 AM
Last Post: stephanh
  How to make a Vocal synthesizer program on Python? Seadust 3 3,491 Jan-28-2021, 06:26 PM
Last Post: gonnach
  How to really use this youtube-upload program in Windows? Jacksonsteel 1 1,605 Dec-18-2020, 07:38 PM
Last Post: snippsat
  Python 3.7, Windows 10, pyinstaller, winsound, no sound in executable kmarien 3 3,592 Nov-30-2020, 04:10 PM
Last Post: buran
  How to make a Python program run in a dos shell (cmd) Pedroski55 2 2,261 Nov-09-2020, 10:17 AM
Last Post: DeaD_EyE
  I try to make Heron formula program abcd 7 3,331 Oct-22-2020, 12:48 AM
Last Post: abcd
  Executable looks like virus to windows samuelbachorik 4 2,977 Apr-27-2020, 02:46 PM
Last Post: samuelbachorik

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020