# "ImportError: DLL load failed" error when trying to import vtk

**URL:** https://discourse.vtk.org/t/importerror-dll-load-failed-error-when-trying-to-import-vtk/12156
**Category:** Support
**Tags:** python
**Created:** [August 16, 2023, 2:15am UTC](https://discourse.vtk.org/t/importerror-dll-load-failed-error-when-trying-to-import-vtk/12156 "2023-08-16T02:15:06Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![engineer](https://discourse.vtk.org/user_avatar/discourse.vtk.org/engineer/32/7612_2.png) [@engineer](https://discourse.vtk.org/u/engineer)
#### Post date: [August 16, 2023, 2:15am UTC](https://discourse.vtk.org/t/importerror-dll-load-failed-error-when-trying-to-import-vtk/12156/1 "2023-08-16T02:15:06Z")

</div>

I’m running python 3.10.9 on Windows 10 Pro. Steps to reproduce: I create a new virtualenv with `python -m venv env` then run `pip install vtk`, which installs vtk version 9.2.6. Then, when I try to simply `import vtk` in the python shell, I get this error:

> File “C:\Users[my name]\Documents\DebuggingVTK\env\lib\site-packages\vtk.py”, line 4, in   
> from vtkmodules.vtkCommonCore import \*  
> ImportError: DLL load failed while importing vtkCommonCore: The specified module could not be found.

I’ve tried running `os.add_dll_directory(r'C:\Users\[my name]\Documents\DebuggingVTK\env\lib\site-packages\vtkmodules')`, but that didn’t change anything. I’ve also tried adding this directory to PATH and PYTHONPATH.

I could possibly build vtk from source, but the project is set up to pip install it from requirements.txt, plus other people might have this issue, so it’d be great to figure out if there’s a workaround this way.

I really appreciate any help. I’ve been stuck on this all day.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [August 17, 2023, 12:18pm UTC](https://discourse.vtk.org/t/importerror-dll-load-failed-error-when-trying-to-import-vtk/12156/2 "2023-08-17T12:18:42Z")

</div>

VTK should be doing `os.add_dll_directory` on its own already. Could you use [`procmon`](https://docs.microsoft.com/en-us/sysinternals/downloads/procmon) to see what DLL is failing to load (you’ll need to set up some filters to make it “useful” for this). I don’t know if Python provides better error messages (maybe 3.11 does?).

---

<div class="post-metadata">

### Author: ![engineer](https://discourse.vtk.org/user_avatar/discourse.vtk.org/engineer/32/7612_2.png) [@engineer](https://discourse.vtk.org/u/engineer)
#### Post date: [August 28, 2023, 1:27pm UTC](https://discourse.vtk.org/t/importerror-dll-load-failed-error-when-trying-to-import-vtk/12156/3 "2023-08-28T13:27:03Z")

</div>

Sorry for the late reply. Upgrading to vtk 9.3.0 fixed my problem. Thanks for the suggestion!
