When creating an executable from a simple Python script, Pyinstaller completes successfully. But when trying to run the executable, it fails with a ModuleNotFoundError
:
Traceback...
ModuleNotFoundError: No module named 'git'
[26228] Failed to execute script xyz
I have installed gitpython via Pipenv. Why is it not bundled correctly?
The answer provided by @vauhochzett is almost correct, but needs a bit of modification as follows. Instead of using pip within pipenv to install pyinstaller, install pyinstaller using pipenv itself.
This means you will need to install pyinstaller into every pipenv you create, but it will sort out the import paths correctly for every venv you use.
Something goes wonky with the import paths when pyinstaller is installed using pip, but everything works as expected when pipenv is used to install the module within the venv as shown below.
$ pipenv install pyinstaller
$ pipenv run pyinstaller script.spec