Using VTK with Python on Windows 10

I am using Python3 on Windows 10 x64. I am using python by using Msys2. I have installed several packages by using Msys2 and they work with python without problems.

I have installed vtk 8.2 by using Msys2. vtk 8.2 is the latest version in the Msys2 resources. Python gives the following error for “import vtk” command:

Traceback (most recent call last):
  File "C:\msys64\mingw64\lib\python3.8\site-packages\vtkmodules\vtkIOGDAL.py", line 5, in <module>
    from .vtkIOGDALPython import *
ImportError: DLL load failed while importing vtkIOGDALPython: The specified module could not be found.

I have looked at the directory but there is no dll files. There are py and pyd files.
I have added following variables as PATH:

C:\msys64\mingw64\bin
C:\msys64\mingw64\lib\python3.8\site-packages\vtkmodules
C:\msys64\mingw64\lib\python3.8\site-packages
C:\msys64\mingw64\lib

But it did not change. Installing vtk by using pip does not work. It gives following error:

ERROR: Could not find a version that satisfies the requirement vtk
ERROR: No matching distribution found for vtk

Python: 3.8.6 (x64)
Msys2: msys2-x86_64-20201109
vtk: 8.2 (x64)
pip: 20.3.3
Pycharm: 2020.3
Windows 10 (x64)

Is there any solution to fix this problem?

You got yourself into a lot of trouble if you use msys on Windows. I would recommend to use Visual Studio Community version instead - it is completely free and can be used without any restrictions. If you want to use msysi then probably you need to build VTK yourself.

Msys2 is advised for installing GTK3 on windows. Otherwise, a lot of compile operations have to be done. I have no problems when using msys2 for packages other than VTK. I don’t know the details of the problems with installation of VTK and msys2 together.

Afaik, VTK does not support msys2.

GTK could be an interesting backup plan, just in case Qt goes really crazy with its licensing terms. However, msys environment has many disadvantages compared to using native build tools, so I would only consider looking at GTK if Visual Studio can be still used for Windows development.