https://github.com/widilo/create_exe_file_from_python_script
Create a Windows Executable from a Python Script
https://github.com/widilo/create_exe_file_from_python_script
Last synced: about 2 months ago
JSON representation
Create a Windows Executable from a Python Script
- Host: GitHub
- URL: https://github.com/widilo/create_exe_file_from_python_script
- Owner: widilo
- License: cc0-1.0
- Created: 2025-01-29T21:17:42.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-01-29T21:51:23.000Z (4 months ago)
- Last Synced: 2025-02-06T03:55:17.529Z (4 months ago)
- Size: 16.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# How to Create a Windows Executable from a Python Script
Turning your Python script into a standalone .exe file is simple with PyInstaller. Follow this guide to generate an executable that can run on Windows without requiring Python installation.
### 1. Install PyInstaller
First, install PyInstaller if you haven’t already:
```bash
pip install pyinstaller
```### 2. Convert the Script to an Executable
Run the following command in the terminal or command prompt:
```bash
pyinstaller --onefile --windowed yourscript.py
```Explanation of Flags:
```bash
--onefile: Creates a single executable instead of multiple files.
--windowed (optional): Hides the console window (useful for GUI applications). Omit this flag for CLI scripts.
```### 3. Find the Executable
After running the command, PyInstaller will generate files in the dist folder. Your `.exe` will be located at:
```bash
dist/yourscript.exe
```### 4. Running the Executable
Navigate to the dist folder and run:
```bash
yourscript.exe
```### 5. (Optional) Add an Icon
If you want to add a custom icon, use:
```bash
pyinstaller --onefile --icon=icon.ico yourscript.py
```Make sure `icon.ico` is in the same directory as your script.
## License
Compare two Excel files using Python by widilo is licensed under CC BY-NC-SA 4.0