Creating a Standalone Executable with PyInstaller
🎥 Video Tutorial
Small video tutorial for Windows and Linux machines below.
1. Install PyInstaller
Open the Windows Command Prompt and run the following command:
```bash pip install pyinstaller ````
Note: This works on Linux as well using the terminal.
2. Create Your Python Script
Create a file named yourprogram.py with the following content:
python
print("Compiled version for Windows")
3. Create the Executable
Run the following command in the terminal or command prompt:
bash
pyinstaller --onefile yourprogram.py
4. Locate and Run the Executable
After the process completes, your executable will be created inside the dist folder.
Example path:
dist/yourprogram.exe
Notes
- The steps are the same on Linux. The resulting binary will be platform-specific (i.e., you must build on Windows for Windows, on Linux for Linux).
- If you want to make a cross-platform binary, consider using a virtual machine or container.