HELP ME – An Error bothers me
ImportError: DLL load failed while importing onnxruntime_pybind11_state: A dynamic link library
I am working on RealtimeSTT GUI python project.
I used RealtimeSTT python package and pyQt5.
I made a exe file from the python scripts with pyinstaller.
But the generated exe file didn’t work well.
The python script works right on command.
So I made an exe file with pyinstaller.
But when I run the exe file, I encountered the below error.
[PYI-27776:DEBUG] LOADER: running pyi_rth_pkgres.py
[PYI-27776:DEBUG] LOADER: running main.py
Traceback (most recent call last):
File "main.py", line 52, in <module>
File "main.py", line 4, in main
File "PyInstallerloaderpyimod02_importers.py", line 457, in exec_module
File "core.py", line 10, in <module>
File "PyInstallerloaderpyimod02_importers.py", line 457, in exec_module
File "RealtimeSTT__init__.py", line 1, in <module>
File "PyInstallerloaderpyimod02_importers.py", line 457, in exec_module
File "RealtimeSTTaudio_recorder.py", line 31, in <module>
File "PyInstallerloaderpyimod02_importers.py", line 457, in exec_module
File "openwakeword__init__.py", line 3, in <module>
File "PyInstallerloaderpyimod02_importers.py", line 457, in exec_module
File "openwakewordvad.py", line 48, in <module>
File "PyInstallerloaderpyimod02_importers.py", line 457, in exec_module
File "onnxruntime__init__.py", line 61, in <module>
File "onnxruntime__init__.py", line 24, in <module>
File "PyInstallerloaderpyimod02_importers.py", line 457, in exec_module
File "onnxruntimecapi_pybind_state.py", line 32, in <module>
ImportError: DLL load failed while importing onnxruntime_pybind11_state: A dynamic link library
(DLL) initialization routine failed.
[PYI-27776:ERROR] Failed to execute script 'main' due to unhandled exception!
[PYI-27776:DEBUG] LOADER: ERROR.
[PYI-27776:DEBUG] LOADER: manually flushing stdout and stderr...
[PYI-27776:DEBUG] LOADER: cleaning up Python interpreter...
[process exited with code 1 (0x00000001)]
This is the spec file for pyinstaller:
# -*- mode: python ; coding: utf-8 -*-
import os
from glob import glob
import onnxruntime
import torch
# from PyInstaller.utils.hooks import collect_dynamic_libs
block_cipher = None
# ---------------------------
# Binaries (DLLs and icon)
# ---------------------------
# PyTorch DLLs
torch_dlls = ['c10.dll', 'torch.dll', 'torch_cpu.dll', 'torch_cuda.dll', 'torch_cuda_cu.dll', 'cudnn*.dll'] # Add 'torch_cuda.dll' if GPU needed
torch_binaries = [(os.path.join(torch.__path__[0], dll), '.') for dll in torch_dlls if os.path.exists(os.path.join(torch.__path__[0], dll))]
# Binaries
binaries = [('icon.ico', '.')] + torch_binaries
# ---------------------------
# Analysis
# ---------------------------
a = Analysis(
['main.py'],
pathex=[],
binaries=binaries,
datas=[('resources/assets/splash.jpg', 'resources/assets')],
hiddenimports=[
'torch',
'torch.nn',
'torchvision',
'torchaudio',
],
hookspath=[],
runtime_hooks=[],
excludes=[],
noarchive=False,
cipher=block_cipher,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
# ---------------------------
# Executable
# ---------------------------
exe = EXE(
pyz,
a.scripts,
# a.binaries,
# a.datas,
[],
name='voicetotext',
icon='icon.ico',
debug=True, # Keep True while debugging
console=True, # Show console for logs
upx=False,
upx_dir="C:/upx",
runtime_tmpdir=os.path.join(os.getenv('TEMP', os.path.expanduser('~')), 'voicetotext'),
)
coll = COLLECT(
exe,
a.binaries,
a.datas,
a.zipfiles,
strip=False,
upx=False,
upx_dir="C:/upx",
upx_exclude=[],
name='voicetotext'
)
Help me.
I expect your kindly helps.