I'm trying to run a python script compiled into a .exe with pyinstaller and I'm running into issues when importing scipy (no issues with other imported packages) :
Traceback (most recent call last):
File "Sim_choix_modal.py", line 15 in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\yimode03_importers.py", line 495, in exec_module
File "scipy\__init__.py, line 76 in <module>
File "scipy\__init__.py, line 67 in _delvewheel_init_patch_1_1_0
File "os.py", line 1111, in add_dll_directory
FileNotFoundError: [WinError 2] Le fichier spécifié est introuvable: 'C:\\Users\\username~1\\AppData\\Local\\Temp\\_MEI155082\\scipy.libs'
[17952] Failed to execute script 'Sim_choix_modal' due to unhandled exception!
Some intel :
- The python script is named 'Sim_choix_modal.py'
- The line 15 in Sim_choix_modal.py is
import scipy
- The french text after [WinError 2] is equivalent to "No such file or directory: 'C:\Users\...".
- To compile my python script I use the command
pyinstaller --onefile Sim_choix_modal.py
I've read similar questions and tried stuff that seemed to work for other users :
Adding the option
--add-data "path/to/venv/Lib/site-packages/scipy.libs;scipy.libs/"
when compiling the .py into a .exe, make the .exe close (crash?) when run, without displaying any error (source : PyInstaller FileNotFoundError "scipy.libs")Add hiddenimports=['scipy._lib.messagestream'] into the spec file (tried before and after compiling the .py into .exe : doesn't seems to change anything, same error message. (source : Error when executing compiled file " No module named 'scipy._lib.messagestream' "after using pyinstaller)
Followed this reply, to no avail : https://stackoverflow.com/a/62238104/22319153 (which if I understood correctly is supposed to add a hook for scipy to pyinstaller)
Thanks in advance for your time,
Paul