vosk-api icon indicating copy to clipboard operation
vosk-api copied to clipboard

Vosk does not work with pyinstaller

Open rodolphonetto opened this issue 3 years ago • 14 comments

Hi, I could make a script that works as a py file, but when I try to run pyinstaller to get an exe of the file I get that error, about the vosk lib, someone knows what can I do?

I dont know how to solve that, it is my first touch with python I'm kind lost

Sem título

rodolphonetto avatar Jun 24 '21 01:06 rodolphonetto

How did you package the exe binary exactly

nshmyrev avatar Jun 24 '21 09:06 nshmyrev

How did you package the exe binary exactly

Thank you for your time, I just installed pyinstaller with pip install pyinstaller and ran that command

pyinstaller --noconsole --debug=all chess.py

I did not done any extra config

rodolphonetto avatar Jun 24 '21 10:06 rodolphonetto

Hello. I had the same problem. The solution that worked for me was to put all the files from site-packages\vosk folder to dist\app\vosk folder.

RaisHibi avatar Jun 26 '21 18:06 RaisHibi

Thanks @RaisHibi, with that fix I cannot use onefile option rigth? But I will test It

For now I using cb_freeze

rodolphonetto avatar Jun 26 '21 19:06 rodolphonetto

The same problem. I obtain this message when try to run exe file.

Traceback (most recent call last):
  File "Vega.py", line 10, in <module>
    from vosk import Model, KaldiRecognizer
  File "C:\Users\Alex\AppData\Local\Temp\embedded.zm51h3af.zip\shibokensupport\__feature__.py", line 142, in _import
  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\pyimod03_importers.py", line 540, in exec_module
  File "vosk\__init__.py", line 21, in <module>
  File "vosk\__init__.py", line 12, in open_dll
  File "os.py", line 1111, in add_dll_directory
FileNotFoundError: [WinError 2] The specified file cannot be found: 'C:\\Users\\Alex\\AppData\\Local\\Temp\\_MEI126762\\vosk'
[920] Failed to execute script Vega

I used pyinstaller.

AlexUser97 avatar Jun 26 '21 19:06 AlexUser97

Thanks @RaisHibi, with that fix I cannot use onefile option rigth? But I will test It

For now I using cb_freeze

I think you can if you add site-packages\vosk folder as data in your .spec file

RaisHibi avatar Jun 26 '21 19:06 RaisHibi

Thanks @RaisHibi, with that fix I cannot use onefile option rigth? But I will test It For now I using cb_freeze

I think you can if you add site-packages\vosk folder as data in your .spec file

I did the copy/paste with the vosk folder and worked greate with pyinstaller thanks!!

But I tried to put it into datas on specs file and received the same error that @AlexUser97 received, someone knows what can we do?

rodolphonetto avatar Jun 27 '21 00:06 rodolphonetto

It worked in my case. Make sure you put the folder into datas correctly. Here's an example: datas = [('...\venv\Lib\site-packages\vosk', './vosk')] So you first mention the site-packages\vosk folder and then say where it is located in your application folder. Onefile option creates only .exe, but when you launch it, every file needed is copyed to your temp folder. And it looks the same as dist folder when you choose onedir option. So everything should work in both cases.

RaisHibi avatar Jun 27 '21 09:06 RaisHibi

Thanks for your help these days @RaisHibi it worked fine now, thank you so much

rodolphonetto avatar Jun 27 '21 14:06 rodolphonetto

Hello everyone, I have the same problem as @AlexUser97 . I tried to solve as wrote @RaisHibi , but nothing came of it, I assume that I did not specify the paths correctly in datas, can anyone help me? -5215204347892315222_121 -5215204347892315223_121

ghost avatar Nov 10 '21 10:11 ghost

I have the same problem as @AlexUser97

Which problem exactly. What is the error message.

nshmyrev avatar Nov 10 '21 11:11 nshmyrev

У меня та же проблема, что и у @ AlexUser97

Какая именно проблема. Что за сообщение об ошибке.

-5206373216526907267_121 Such an error on startup

ghost avatar Nov 10 '21 11:11 ghost

I had the same error and fixed by copying directory site-packages/vosk into distributed dir.

acro5piano avatar Jun 15 '22 02:06 acro5piano

The same problem. I obtain this message when try to run exe file.

Traceback (most recent call last):
  File "Vega.py", line 10, in <module>
    from vosk import Model, KaldiRecognizer
  File "C:\Users\Alex\AppData\Local\Temp\embedded.zm51h3af.zip\shibokensupport\__feature__.py", line 142, in _import
  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\pyimod03_importers.py", line 540, in exec_module
  File "vosk\__init__.py", line 21, in <module>
  File "vosk\__init__.py", line 12, in open_dll
  File "os.py", line 1111, in add_dll_directory
FileNotFoundError: [WinError 2] The specified file cannot be found: 'C:\\Users\\Alex\\AppData\\Local\\Temp\\_MEI126762\\vosk'
[920] Failed to execute script Vega

I used pyinstaller.

pyinstaller --noconsole --onefile --collect-all vosk test.py worked for me. None of the other methods worked sadly.

JoraSN avatar Aug 24 '23 22:08 JoraSN