Error when tying to execute the .exe generated by pyinstaller

668 Views Asked by At

I just finished a project and want to convert it to a executable. When using pyinstaller with the command pyinstaller --onefile Music_sorter_by_Fabrice_Schöneberger.py it compiles without an error. But when executing the file I get the following:

  File "Music_sorter_by_Fabrice_Schöneberger.py", line 1, 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\pyimod02_importers.py", line 352, in exec_module
  File "librosa\__init__.py", line 215, in <module>
  File "lazy_loader\__init__.py", line 243, in attach_stub
ValueError: Cannot load imports from non-existent stub 'C:\\Users\\fabri\\AppData\\Local\\Temp\\_MEI157482\\librosa\\__init__.pyci'
[1588] Failed to execute script 'Music_sorter_by_Fabrice_Sch÷neberger' due to unhandled exception!

The folders ...\_MEI157482\\librosa\\__init__.pyci don't exist (the before does) and if I look within the librosa installation I can't find a file named __init__.pyci. I have a __init__.pyi and __init__.py. I don't find such a file online so I hope someone here can help me.

Edit: The problem is not pyinstaller specific. py2exe has the exact same problem, that I can't find a __init___.pyci. I think i might be that the installers can't complile librosa correctly?

1

There are 1 best solutions below

1
Pepe On

add an specific hook for librosa worked for me, using Auto-py-to-exe.

Create a folder named "extra-hooks", and in it a file "hook-librosa.py" paste these 2 lines in "extra-hooks/hook-librosa.py":

from PyInstaller.utils.hooks import collect_data_files
datas = collect_data_files('librosa')

Then tell where to locate this file with adding the following command in Settings>Manually Provide Options:

--additional-hooks-dir "[PATH_TO_YOUR_PROJECT]/axtra-hooks"

source of the solution: https://github.com/librosa/librosa/issues/538