英文:
Python OpenAI Whisper FileNotFoundError when running a standalone created with PyInstaller
问题
我创建了一个使用OpenAI whisper库的小型Python程序。在我的虚拟环境中一切正常。
我使用PyInstaller生成了整个项目的.exe
文件,但当我运行生成的文件时,出现以下错误:
线程启动时忽略的异常: <function start_interpretor at 0x000001F9EC80F430>
Traceback (most recent call last):
File "interpretor.py", line 67, in start_interpretor
File "transcriber.py", line 125, in run_transcription
File "transcriber.py", line 88, in progress_transcription
File "whisper\transcribe.py", line 121, in transcribe
File "whisper\audio.py", line 141, in log_mel_spectrogram
File "whisper\audio.py", line 94, in mel_filters
File "numpy\lib\npyio.py", line 405, in load
FileNotFoundError: [Errno 2] 没有这样的文件或目录: 'C:\\Users\\Div-o\\AppData\\Local\\Temp\\_MEI236562\\whisper\\assets\\mel_filters.npz'
我尝试将数据对象添加到由PyInstaller生成的.spec
文件:
a = Analysis(
//...
datas=[('.venv/Lib/site-packages/whisper/assets/mel_filters.npz', '.venv/Lib/site-packages/whisper/assets'),],
//...
)
我甚至在同一文件中的EXE()
中添加了recursive_copy_metadata="whisper"
,但问题仍然存在。
知道是什么原因导致了这个问题吗?
英文:
I made a small Python program that uses OpenAI whisper's library. Everything works fine in my virtual environment.
I generated a .exe
of the whole thing with PyInstaller, but when I run the resulting file, I get the following error:
Exception ignored in thread started by: <function start_interpretor at 0x000001F9EC80F430>
Traceback (most recent call last):
File "interpretor.py", line 67, in start_interpretor
File "transcriber.py", line 125, in run_transcription
File "transcriber.py", line 88, in progress_transcription
File "whisper\transcribe.py", line 121, in transcribe
File "whisper\audio.py", line 141, in log_mel_spectrogram
File "whisper\audio.py", line 94, in mel_filters
File "numpy\lib\npyio.py", line 405, in load
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Div-o\\AppData\\Local\\Temp\\_MEI236562\\whisper\\assets\\mel_filters.npz'
I have tried to add the datas object to the .spec
file generated by PyInstaller:
a = Analysis(
//...
datas=[('.venv/Lib/site-packages/whisper/assets/mel_filters.npz', '.venv/Lib/site-packages/whisper/assets'),],
//...
)
I even added recursive_copy_metadata="whisper"
to the EXE()
in the same file, but the issue persists.
Any idea what is causing that?
答案1
得分: 1
我通过使用 faster-whisper
解决了它。
另外,你的数据应该大致如下:
a = Analysis(
//...
datas=[('.venv\\Lib\\site-packages\\whisper\\assets\\mel_filters.npz', '\\whisper\\assets'),],
//...
)
英文:
I solved it by using faster-whisper
.
Also your datas should probably look like this:
a = Analysis(
//...
datas=[('.venv\\Lib\\site-packages\\whisper\\assets\\mel_filters.npz', '\\whisper\\assets'),],
//...
)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论