HELP ME - An Error bothers me

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MyrinNew
    Senior Member
    • Feb 2024
    • 5175

    #1

    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-27776EBUG] LOADER: running pyi_rth_pkgres.py
    [PYI-27776EBUG] LOADER: running main.py
    Traceback (most recent call last):
    File "main.py", line 52, in
    File "main.py", line 4, in main
    File "PyInstaller\loader\pyimod02_importers.py", line 457, in exec_module
    File "core.py", line 10, in
    File "PyInstaller\loader\pyimod02_importers.py", line 457, in exec_module
    File "RealtimeSTT\__init__.py", line 1, in
    File "PyInstaller\loader\pyimod02_importers.py", line 457, in exec_module
    File "RealtimeSTT\audio_recorder.py", line 31, in
    File "PyInstaller\loader\pyimod02_importers.py", line 457, in exec_module
    File "openwakeword\__init__.py", line 3, in
    File "PyInstaller\loader\pyimod02_importers.py", line 457, in exec_module
    File "openwakeword\vad.py", line 48, in
    File "PyInstaller\loader\pyimod02_importers.py", line 457, in exec_module
    File "onnxruntime\__init__.py", line 61, in
    File "onnxruntime\__init__.py", line 24, in
    File "PyInstaller\loader\pyimod02_importers.py", line 457, in exec_module
    File "onnxruntime\capi\_pybind_state.py", line 32, in
    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-27776EBUG] LOADER: ERROR.
    [PYI-27776EBUG] LOADER: manually flushing stdout and stderr...
    [PYI-27776EBUG] 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.




    More...
Working...