Python DLL import error when importing vtk

2019-05-14 03:47发布

问题:

I need to use the VTK library (with version 5.10 because I am working on an existing code) in python on my Windows 10 machine but I can not manage to import it without DLLImport error:

Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import vtk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\vtk\__init__.py", line 139, in <module>
    __helper.refine_import_err('qvtk', 'vtkQtPython', exc)
  File "C:\Python27\lib\site-packages\vtk\__helper.py", line 32, in refine_import_err
    raise LinkError, str(exc)
vtk.__helper.LinkError: DLL load failed: The specified module could not be found.

I have installed PyQt4 4.11.4 and VTK 5.10.1 in 32 bits version (my Python 2.7.12 installation is 32 bits too), downloaded here: http://www.lfd.uci.edu/~gohlke/pythonlibs/

I think the issue is related to the vtkQtPython pyd and dll (the files are vtkQtPython.pyd which tries to load vtkQtPythonD.dll:

>>> import qvtk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "qvtk.py", line 5, in <module>
    from vtkQtPython import *
ImportError: DLL load failed: The specified module could not be found.
>>> import vtkQtPython
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified module could not be found.

Importing vtk using the latest version (7.0.0) does work, but is not compatible with the code I am working on. I have already tried uninstalling and set-up the whole installation again (all libraries and Python itself).

I hope you'll find some ideas, I still could not find any solution after hours struggling.