An open API service indexing awesome lists of open source software.

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

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