How do I make a python executable in Windows?
Answer
On Windows, the standard Python installer already associates the .py extension with a file type (Python.File) and gives that file type an open command that runs the interpreter ( D:\Program Files\Python\python.exe “%1” %* ). This is enough to make scripts executable from the command prompt as ‘foo.py’.
Run your script
This appendix will show you how to compile your .py Python files into .exe programs that can be run on Windows without having Python installed.
Run the Python command-line interpreter, under your OS of choice,
Answer
On Windows, the standard Python installer already associates the .py extension with a file type (Python.File) and gives that file type an open command that runs the interpreter ( D:\Program Files\Python\python.exe “%1” %* ). This is enough to make scripts executable from the command prompt as ‘foo.py’.
Code:
https://commons.wikimedia.org/wiki/File:DandEror.png
- Open Command line: Start menu -> Run and type cmd.
- Type: C:\python27\python.exe Z:\code\hw01\script.py.
- Or if your system is configured correctly, you can drag and drop your script from Explorer onto the Command Line window and press enter.
This appendix will show you how to compile your .py Python files into .exe programs that can be run on Windows without having Python installed.
- Step 1: Download and Install py2exe.
- Step 2: Create Your setup.py Script.
- Step 3: Run Your setup.py Script.
- Step 4: Distribute Your Program.
Run the Python command-line interpreter, under your OS of choice,
- Open Command line: Start menu -> Run and type cmd.
- Type: C:\python27\python.exe.
- Note: This is the default path for Python 2.7. If you are using a computer where Python is not installed in this path, change the path accordingly.