1

I have installed python on Windows through Python (X,Y) v2.7.10. If I try to import the module vtk.tk.vtkTkRenderWindowInteractor, I get the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\vtk\tk\vtkTkRenderWindowInteractor.py", line 16, in <module>
    from vtkLoadPythonTkWidgets import vtkLoadPythonTkWidgets
  File "C:\Python27\lib\site-packages\vtk\tk\vtkLoadPythonTkWidgets.py", line 2, in <module>
    import vtkCommonCorePython
ImportError: No module named vtkCommonCorePython

The PATH variable is correctly set, and contains "C:\Python27\Lib\site-packages\vtk", wich contains the file vtkCommonCorePython.pyd.

Has anyone had this issue or has a solution?

Edit: Solved but won't work

VTK has decided to drop support for Tkinter widgets, so if You, like me, want it back, we can ask for it here: http://vtk.uservoice.com/forums/31508-general/suggestions/9291084-return-support-for-tkinter-widgets

guillegiraldo
  • 51
  • 1
  • 8
  • I'm having a problem that might be related, or might be the same problem. I posted my question here: http://stackoverflow.com/questions/31883557/how-do-i-use-liclipse-to-write-a-paraview-script – GregNash Aug 07 '15 at 18:02
  • @GregNash I suposse it's related because the problem is the module "vtkCommonCorePython", wich is not found in both cases. However, while I'm using it through vtk.tk, you are using it through paraview. Both rely on the vtk library. How did you install python and vtk? – guillegiraldo Aug 07 '15 at 20:51
  • I installed Python from Python.org's download page and I installed vtk by installing Paraview from ParaView.org's download page. – GregNash Aug 10 '15 at 14:52
  • My problem has been resolved. I added the path variables that I used to the bottom of my question as an edit. – GregNash Aug 10 '15 at 15:54
  • Thanks @GregNash, I found the solution as you can see in the answer. Anyway, it only unmasked another (deeper) problem in VTK, so the happiness is not complete. – guillegiraldo Aug 10 '15 at 19:54

2 Answers2

0

Thanks to @GregNash, and his question How do I use Liclipse to write a ParaView script? I found the solution.

Python(x,y) didn't create the environment variable PYTHONPATH. Simply creating the variable solved the problem:

PYTHONPATH: C:\Python27\Lib\site-packages\vtk;
Community
  • 1
  • 1
guillegiraldo
  • 51
  • 1
  • 8
0

I had the same problem : the file vtkCommonCorePython.pyd (vtkCommonCorePython.so on linux) was in the directory site-packages\vtk (or equivalent on Linux), but the module could not be imported.

This was fixed by replacing all occurences of "vtkCommonCorePython" by "vtk.vtkCommonCorePython" in the file site-packages\vtk\tk\vtkLoadPythonTkWidgets.py

Another problem might be that your vtk version was not compiled with Tk support; in this case the file vtkCommonCorePython.pyd would not be there.

  • Thanks for the tip. Yes, that version of vtk was not compiled with Tk support. I went as far as to compile it myself to get the libraries. – guillegiraldo Aug 31 '16 at 13:40