Calling PyInstaller’s built frontend from a script can be annoying as the typically-used pyinstaller .exe script is not a runnable module but a separate entry-point script built at install time. You can tell this from the [project.scripts] section in PyInstaller’s pyproject.toml.
Instead, you can write a very small Python entry point script of your own, which you can then call however you like:
import PyInstaller.__main__ as m
if __name__ == '__main__':
m._console_script_run()Then, simply run this as a normal Python script, but all arguments are passed through to PyInstaller:
python pyi_alternative.py /my/spec/file.specThe nice thing about this approach is that it lets you easily switch between multiple Python versions, especially when using the Windows Py Install Manager approach — using py pyi_alternative.py ... selects your preferred installation to build with.