# VTK build fails on Windows when Python type hints are requested (VTK\_BUILD\_PYI\_FILES)

**URL:** https://discourse.vtk.org/t/vtk-build-fails-on-windows-when-python-type-hints-are-requested-vtk-build-pyi-files/16192
**Category:** Support
**Tags:** windows, python, build
**Created:** [December 18, 2025, 4:46pm UTC](https://discourse.vtk.org/t/vtk-build-fails-on-windows-when-python-type-hints-are-requested-vtk-build-pyi-files/16192 "2025-12-18T16:46:22Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![scotsman60](https://discourse.vtk.org/user_avatar/discourse.vtk.org/scotsman60/32/6000_2.png) [@scotsman60](https://discourse.vtk.org/u/scotsman60)
#### Post date: [December 18, 2025, 4:46pm UTC](https://discourse.vtk.org/t/vtk-build-fails-on-windows-when-python-type-hints-are-requested-vtk-build-pyi-files/16192/1 "2025-12-18T16:46:22Z")

</div>

Hello,

I’m building VTK 9.5.2 on Windows and all is well until I request Python type hints with VTK\_BUILD\_PYI\_FILES.

The build fails with the following error

`Severity	Code	Description	Project	File	Line	Suppression State	Details`  
`Error	MSB8066	Custom build for ‘E:\Software\vtk\build\CMakeFiles\05cf3c8b85c8aaf14b881db917599f06\vtkCommonCore.pyi.rule;E:\Software\vtk\build\CMakeFiles\ab3ac9675c28ecbf447909429c8c7300\vtkpythonmodules_pyi.rule;E:\Software\vtk\source\CMakeLists.txt’ exited with code 1.	vtkpythonmodules_pyi	C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets	254`

Any ideas on what could be wrong here?

Thanks in advance,

Doug

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [December 19, 2025, 2:50am UTC](https://discourse.vtk.org/t/vtk-build-fails-on-windows-when-python-type-hints-are-requested-vtk-build-pyi-files/16192/2 "2025-12-19T02:50:36Z")

</div>

I did a test build with the Visual Studio generator to see what is going on. Scrolling up through the build log provides the actual error:

```auto
    File "E:\Software\vtk-build\lib\site-packages\vtkmodules\generate_pyi.py", line 38, in <module>
      from vtkmodules.vtkCommonCore import vtkObjectBase, vtkSOADataArrayTemplate
  ImportError: DLL load failed while importing vtkCommonCore: The specified module could not be found.

```

Seems the issue is in `vtkmodules/ __init__.py`, which assumes the VTK DLLs are in `vtk-build/bin`. For the Visual Studio generators, the DLLs are actually in `vtk-build/bin/Release` or `vtk-build/bin/Debug`. As a result, the vtk-python modules are unable to load the VTK DLLs from the build tree.

There are two work-arounds that I can think of:

1. Intsead of setting `VTK_BUILD_PYI_FILES` during configuration, do a normal VTK build followed by install and then run `python -m vtkmodules.generate_pyi` manually. Since the DLLs are in “bin/” in the install tree (e.g. not in “bin/Release/” like in the build tree), vtk-python will be able to use the installed DLLs.
2. The easiest solution is probably to use Ninja instead of MSBuild, since Ninja doesn’t use Release & Debug subdirectories.

---

<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: [December 22, 2025, 3:24pm UTC](https://discourse.vtk.org/t/vtk-build-fails-on-windows-when-python-type-hints-are-requested-vtk-build-pyi-files/16192/3 "2025-12-22T15:24:36Z")

</div>

Note that it was my idea that libraries would actually be in `<builddir>/Debug/bin` (basically, the config is shared between all types and at the top so that the install prefix layout looks Unix-y). Work towards realizing that goal would be greatly appreciated.
