2025, Oct 28 09:00
How to stop labelme crashing on Windows: fix onnxruntime ImportError, NumPy 2 ABI and DLL issues
Troubleshoot labelme not opening on Windows. Fix onnxruntime ImportError, NumPy 2 ABI and DLL load failures by creating a venv and importing onnxruntime first
When you install labelme and try to launch it on Windows, the app can crash before the GUI even appears. The failure often shows up as an ImportError from onnxruntime or a NumPy ABI complaint. Below is a reproducible path to the error and a fix that gets the GUI to open.
Reproducing the problem
After installing the usual stack in a Windows environment, launching labelme fails from the terminal.
pip install labelme opencv-python tensorflow matplotlib albumentations
labelme
The run aborts with a traceback centered on onnxruntime.
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\Otaku\AppData\Local\Programs\Python\Python312\Scripts\labelme.exe\__main__.py", line 4, in <module>
  File "C:\Users\Otaku\AppData\Local\Programs\Python\Python312\Lib\site-packages\labelme\__main__.py", line 17, in <module>
    from labelme.app import MainWindow
  File "C:\Users\Otaku\AppData\Local\Programs\Python\Python312\Lib\site-packages\labelme\app.py", line 21, in <module>
    from labelme._automation import bbox_from_text
  File "C:\Users\Otaku\AppData\Local\Programs\Python\Python312\Lib\site-packages\labelme\_automation\bbox_from_text.py", line 6, in <module>
    import osam
  File "C:\Users\Otaku\AppData\Local\Programs\Python\Python312\Lib\site-packages\osam\__init__.py", line 5, in <module>
    from . import apis  # noqa: F401
  File "C:\Users\Otaku\AppData\Local\Programs\Python\Python312\Lib\site-packages\osam\apis.py", line 5, in <module>
    import onnxruntime
  File "C:\Users\Otaku\AppData\Local\Programs\Python\Python312\Lib\site-packages\onnxruntime\__init__.py", line 61, in <module>
    raise import_capi_exception
  File "C:\Users\Otaku\AppData\Local\Programs\Python\Python312\Lib\site-packages\onnxruntime\__init__.py", line 24, in <module>
    from onnxruntime.capi._pybind_state import (
  File "C:\Users\Otaku\AppData\Local\Programs\Python\Python312\Lib\site-packages\onnxruntime\capi\_pybind_state.py", line 32, in <module>
    from .onnxruntime_pybind11_state import *  # noqa
ImportError: DLL load failed while importing onnxruntime_pybind11_state: A dynamic link library (DLL) initialization routine failed.
Trying to check onnx from the shell may also fail:
onnx --help
onnx : The term 'onnx' is not recognized as the name of a cmdlet, function, script file, or operable program.
Installing onnxruntime-directml and re-running can switch the failure into a NumPy/ABI error and then another import error.
A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.1.3 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.
If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.
Traceback (most recent call last):  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\Otaku\AppData\Local\Programs\Python\Python312\Scripts\labelme.exe\__main__.py", line 4, in <module>
    from labelme.__main__ import main
  File "C:\Users\Otaku\AppData\Local\Programs\Python\Python312\Lib\site-packages\labelme\__main__.py", line 17, in <module>
    from labelme.app import MainWindow
  File "C:\Users\Otaku\AppData\Local\Programs\Python\Python312\Lib\site-packages\labelme\app.py", line 21, in <module>
    from labelme._automation import bbox_from_text
  File "C:\Users\Otaku\AppData\Local\Programs\Python\Python312\Lib\site-packages\labelme\_automation\bbox_from_text.py", line 6, in <module>
    import osam
  File "C:\Users\Otaku\AppData\Local\Programs\Python\Python312\Lib\site-packages\osam\__init__.py", line 5, in <module>
    from . import apis  # noqa: F401
  File "C:\Users\Otaku\AppData\Local\Programs\Python\Python312\Lib\site-packages\osam\apis.py", line 5, in <module>
    import onnxruntime
  File "C:\Users\Otaku\AppData\Local\Programs\Python\Python312\Lib\site-packages\onnxruntime\__init__.py", line 23, in <module>
    from onnxruntime.capi._pybind_state import ExecutionMode  # noqa: F401
  File "C:\Users\Otaku\AppData\Local\Programs\Python\Python312\Lib\site-packages\onnxruntime\capi\_pybind_state.py", line 32, in <module>
    from .onnxruntime_pybind11_state import *  # noqa
AttributeError: _ARRAY_API not found
... later ...
ImportError
What’s going on
The traceback shows labelme pulling in its automation path, which imports onnxruntime through osam. The failure surfaces while importing onnxruntime’s compiled extension, reporting a DLL initialization error in one case. In another case, the output explicitly states that a module compiled against NumPy 1.x cannot run on NumPy 2.1.3, and then raises an AttributeError, which again points to import-time issues inside the compiled onnxruntime bindings.
Attempts like reinstalling packages, restarting, switching Python versions, or moving to a new venv from the integrated VS Code terminal may not change the outcome.
Working fix
Creating a fresh environment from the regular Windows PowerShell and forcing onnxruntime to import before labelme’s GUI wiring resolves the launch.
mkdir tmp; cd tmp; python -m venv venv; . venv/Scripts/Activate.ps1; pip install labelme; labelme --help
Then open labelme’s package entry file in your editor from the same PowerShell session.
code venv/Lib/site-packages/labelme/__init__.py
Add a single import at the very top.
import onnxruntime
Save the file, return to the same PowerShell window, and run labelme. The GUI should open.
Why this matters
Labeling tools are often thin wrappers around a mix of pure Python, compiled extensions, and optional ML runtimes. When import chains reach into components like onnxruntime, the environment must be consistent enough to load those native pieces. The error text here explicitly mentions a NumPy 1.x versus 2.x incompatibility for some compiled modules and a DLL initialization failure for the onnxruntime binding, which explains why the app crashed before drawing a window.
Takeaways
If labelme fails to start on Windows with errors tied to onnxruntime, start from a clean virtual environment created via the regular Windows PowerShell and install only what’s needed. Launching labelme once to verify the entry point and then inserting import onnxruntime at the start of labelme’s __init__.py can make the GUI load. If you also see the NumPy message about 1.x modules not running on NumPy 2, that output itself describes the available paths, but in this case the PowerShell workflow with the explicit import was sufficient to get labelme working.