How can I make a Python script standalone executable to run without ANY dependency? [duplicate]

You can use PyInstaller to package Python programs as standalone executables. It works on Windows, Linux, and Mac.

PyInstaller Quickstart

Install PyInstaller from PyPI:

pip install pyinstaller

Go to your program’s directory and run:

pyinstaller yourprogram.py

This will generate the bundle in a subdirectory called dist.

pyinstaller -F yourprogram.py

Adding -F (or –onefile) parameter will pack everything into single “exe”.

pyinstaller -F --paths=<your_path>\Lib\site-packages  yourprogram.py

running into “ImportError” you might consider side-packages.

 pip install pynput==1.6.8

still runing in Import-Erorr – try to downgrade pyinstaller – see Getting error when using pynput with pyinstaller

For a more detailed walkthrough, see the manual.

Leave a Comment