0

I have built manually VTK 8.1, enabling the modules for vtkPython, vtkWrappingPythonCore, VTK_WRAP_PYTHON and VTK_ENABLE_VTKPYTHON, but I cannot seem to get it to work. I am using and built VTK with Python 3.5.0 on a Windows 10 machine.

When I from vtk import * in a cmd python interpreter, I get a PyThreadState_Get: no current thread error, when I from vtk import * in the vtkPython shell I get this:

Traceback (most recent call last):
  File "D:\Users\Sandro Massa\Code\vtk-git\install\lib\python3.5\site-packages\vtk\vtkCommonCore.py", line 5, in <module>
    from .vtkCommonCorePython import *
ImportError: No module named 'vtk.vtkCommonCorePython'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Users\Sandro Massa\Code\vtk-git\install\lib\python3.5\site-packages\vtk\__init__.py", line 7, in <module>
    from .vtkCommonCore import *
  File "D:\Users\Sandro Massa\Code\vtk-git\install\lib\python3.5\site-packages\vtk\vtkCommonCore.py", line 9, in <module>
    from vtkCommonCorePython import *
ImportError: No module named 'vtkCommonCorePython'

I have the following directories in my PATH variable:

C:\Program Files\Python 3.5\Lib\site-packages
C:\Program Files\Python 3.5\Lib\site-packages\vtk
D:\Users\user\Code\vtk-git\install\bin

and in my PYTHONPATH variable:

C:\Program Files\Python 3.5\Lib\site-packages
C:\Program Files\Python 3.5\Lib\site-packages\vtk

The vtkCommonCorePython.pyc is accessible from both the PATH and the PYTHONPATH, I don't know what else to do. Any ideas?

Sandro Massa
  • 98
  • 1
  • 10
  • Your installation directories (naming) are a little unfamiliar to me. My recommendation is not to have anything in your PATH variable (python or vtk related). Preferable use a virtual environment and activate this. What you need to have in your path inside pyth is `site-packages` and `site-packages/vtk` and the install or build binary folder from `vtk`. If VTK is installed using pip also, it will fail. – Jens Munk Jul 02 '21 at 12:39
  • Hi @JensMunk! Thanks for your comment. I did not install vtk through pip, I changed the PATH and PYTHONPATH as you suggested, and now I get a slightly different error. Instead of "No module named 'vtkCommonCorePython'" I get "DLL load failed: Could not find the specified module". I also re-installed VTK leaving the default options so now the paths are all `C:\Program Files (x86)\VTK` and then I put `lib\python3.5\site-packages`, `lib\python3.5\site-packages\vtk`, `bin`, `lib` in this order – Sandro Massa Jul 07 '21 at 11:51
  • 1
    The DLL load failed is due to python cannot find a DLL. Add the location of the VTK DLLs (where VTK is installed or built) and VTK .pyd files (the python wrapper) to `sys.path` and add the locations using `os.add_dll_directory` also. This is needed for Python 3.8+ – Jens Munk Jul 07 '21 at 12:58

0 Answers0