I am trying to package my python application for other users that dont have python installed. I use pyinstaller
.
My application has multiple dependencies which I e.g. import via import numpy as
So far I have tried:
pyinstaller --paths venv\Lib\site-packages --onefile Main.py
The packaging runs without errors. But when trying to open the .exe file I get:
(venv) PROJECT_DIR>dist\Main.exe
Traceback (most recent call last):
File "Main.py", line 6, in <module>
from LinearProgram import LinearProgram
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "LinearProgram.py", line 3, in <module>
import scipy.optimize
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "scipy\optimize\__init__.py", line 401, in <module>
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "scipy\optimize\_minimize.py", line 27, in <module>
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "scipy\optimize\_trustregion_constr\__init__.py", line 4, in <module>
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "scipy\optimize\_trustregion_constr\minimize_trustregion_constr.py", line 5, in <module>
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "scipy\optimize\_constraints.py", line 8, in <module>
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "numpy\testing\__init__.py", line 12, in <module>
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "numpy\testing\_private\extbuild.py", line 11, in <module>
ModuleNotFoundError: No module named 'numpy.distutils'
[3812] Failed to execute script 'Main' due to unhandled exception!
I have verified that the application is working when running python Main.Py
I also tried installing the missing pakachges manually with:
pyinstaller --onefile --hidden-import numpy --hidden-import scipy --hidden-import matplotlib Main.py
This leads to the exact same error.
I also tried it with --hidden-import numpy.distutils
which also didnt work.
Does anybody have suggestions on how to package all my dependencies?
I've got the same issue (windows, python 3.9, pyinstaller 4.7, numpy 1.22). pyinstaller 4.7 is not compatible with numpy 1.22.
Short term solution : downgrade numpy to 1.21.5.
Long term solution : waiting for pyinstaller update (hook numpy)
You can submit this bug to https://github.com/pyinstaller/pyinstaller/wiki/How-to-Report-Bugs
Hope that will be helpful.