I am trying to create a small program that works with OpenAI's Whisper. I then build the Python script to the .exe file using PyInstaller (auto-py-to-exe). When I run the .exe file, I get the following error:
Traceback (most recent call last):
File "transformers\utils\versions.py", line 108, in require_version
File "importlib\metadata\__init__.py", line 996, in version
File "importlib\metadata\__init__.py", line 969, in distribution
File "importlib\metadata\__init__.py", line 548, in from_name
importlib.metadata.PackageNotFoundError: No package metadata was found for tqdm
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "Whisper.py", line 2, in <module>
File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
File "whisper\__init__.py", line 12, in <module>
File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
File "whisper\decoding.py", line 11, in <module>
File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
File "whisper\tokenizer.py", line 8, in <module>
File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
File "transformers\__init__.py", line 30, in <module>
File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
File "transformers\dependency_versions_check.py", line 41, in <module>
File "transformers\utils\versions.py", line 123, in require_version_core
File "transformers\utils\versions.py", line 110, in require_version
importlib.metadata.PackageNotFoundError: No package metadata was found for The 'tqdm>=4.27' distribution was not found and is required by this application.
Try: pip install transformers -U or pip install -e '.[dev]' if you're working with git main
[10092] Failed to execute script 'Whisper' due to unhandled exception!
This is the source code of my program:
import whisper
import os
from timeit import default_timer as timer
start = timer()
audio_file = "MyAudioFile.wav"
model = whisper.load_model("small")
options = {"language": "de"}
res = model.transcribe(f"C:/Users/Username/Desktop/Transcribe/{audio_file}", **options)
end = timer()
os.system("cls")
print(res["text"])
print("\nFinished in " + str(end-start) + " seconds!")
input("Press ENTER to close the program.")
Everything works without problems when I run the Python script from the console or from VS code. However, unfortunately not when I start it as .exe.
I have already tried to reinstall the packages such as tqdm with pip, without success.
I am grateful for any help and hints!
My problem was solved by adding
--recursive-copy-metadata "openai-whisper"
to the PyInstaller command.