Skip to content

Building an Executable

TFD-42 edited this page Aug 13, 2026 · 1 revision

Building an Executable (PyInstaller)

pip install pyinstaller psutil networkx matplotlib requests
pyinstaller --onefile --console --name ProcessAnalyzer \
  --collect-all psutil \
  --collect-submodules matplotlib \
  process_analyzer_allinone.py

The executable lands in dist/. Rules learned the hard way:

  • Install all dependencies in the SAME environment as pyinstaller. PyInstaller only bundles what it can see installed at build time.
  • --collect-all psutil is mandatory. psutil ships an OS-specific compiled extension (_psutil_osx / _psutil_linux / _psutil_windows) that PyInstaller misses on its own; without the flag the build succeeds but the binary crashes at launch with missing module(s): psutil.
  • --console is mandatory — the wizard and the "press a key" pause need a visible console.
  • No cross-compilation: build on the OS you target.
  • In a compiled executable, missing dependencies are not auto-installed at runtime (that would be a build bug) — the binary prints a clear message and exits cleanly.
  • On macOS, Gatekeeper will block the unsigned binary on first launch: right-click → Open, or xattr -cr dist/ProcessAnalyzer.
  • Android/Termux cannot be targeted at all — see Android / Termux.

If another module is reported missing at runtime, first check pip show <module> in the environment used to run pyinstaller before adding a --collect-all for it.

Clone this wiki locally