Last modified: May 26, 2025 By Alexander Williams
How to Install PyInstaller for Python
PyInstaller is a powerful tool for converting Python scripts into standalone executables. It works on Windows, macOS, and Linux. This guide will help you install PyInstaller easily.
Table Of Contents
Prerequisites
Before installing PyInstaller, ensure you have Python installed. If not, check our guide on Install Python on macOS with Homebrew or Install Python on Fedora Easily.
Verify Python installation by running:
python --version
Python 3.9.7
Install PyInstaller Using pip
The easiest way to install PyInstaller is via pip
. Open your terminal or command prompt and run:
pip install pyinstaller
This will download and install PyInstaller and its dependencies. For a system-wide installation, use sudo
on Linux/macOS.
Verify the Installation
Check if PyInstaller is installed correctly:
pyinstaller --version
4.9
Using PyInstaller
To convert a Python script to an executable, navigate to your script's directory and run:
pyinstaller your_script.py
This creates a dist folder containing the executable. For a single-file executable, use:
pyinstaller --onefile your_script.py
Advanced Options
PyInstaller offers many options. For example, to add an icon:
pyinstaller --onefile --icon=app.ico your_script.py
To exclude unnecessary files, use:
pyinstaller --exclude-module=unnecessary_module your_script.py
Troubleshooting
If you encounter errors, ensure all dependencies are installed. For complex projects, consider tools like Nuitka or cx_Freeze.
Conclusion
PyInstaller simplifies converting Python scripts to executables. With just a few commands, you can distribute your applications easily. For more Python tips, explore our other guides.