Skip to content

Instantly share code, notes, and snippets.

@jftuga
Last active November 13, 2021 08:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jftuga/438d3a7cd52f6bc6e6e6eb7fad6b16a4 to your computer and use it in GitHub Desktop.
Save jftuga/438d3a7cd52f6bc6e6e6eb7fad6b16a4 to your computer and use it in GitHub Desktop.
HOWTO: Create a PyInstaller .exe for a package that uses setup tools

HOWTO: Create a PyInstaller .exe for a package that uses setup tools

Tested with Python 3.10 and PyInstaller 4.7

See also: pyinstaller-setuptools GitHub

Example

Desired package/program is called: alpha.exe

git clone https://example.com/user/alpha
python -m venv alpha
cd alpha
scripts\activate
pip list
python.exe -m pip install --upgrade pip
pip install wheel
# edit requirements.txt and append: pyinstaller
# if there is no requirements.txt file, then edit 'install_requires' section of setup.py
pip install -r .\requirements.txt
pip install pyinstaller-setuptools

# edit setup.py (see below)

python .\setup.py build
python .\setup.py install
python .\setup.py pyinstaller -- -F --noupx
cd dist
dir
# you should now see: alpha.exe

setup.py edits

Use this:

from pyinstaller_setuptools import setup
from setuptools import find_packages

Instead of this:

from setuptools import setup, find_packages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment