[vtkusers] How to import vtk in python?

David Thompson david.thompson at kitware.com
Thu May 21 21:05:45 EDT 2015


Hi Lin,

This problem is usually caused because VTK libraries and Python files are not installed in Python's default search paths. Try setting the PYTHONPATH environment variable to include VTK's lib and lib/site-packages directories.

Alternatively, instead of running Python, run the vtkpython program that gets built as part of VTK. It automatically adds the correct search paths and starts up a Python interpreter for you.

	David

> On May 21, 2015, at 9:02 PM, Lin M <majcjc at gmail.com> wrote:
> 
> Hi all,
> 
> When I'm trying to import vtk in python 2.7, it showed that
> 
> >>> import vtk
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "C:\Users\Marlin\Documents\Projects\VTK\VTK-dev\bin\Wrapping\Python\vtk\__init__.py", line 39, in <module>
>     from vtkCommonCore import *
>   File "C:\Users\Marlin\Documents\Projects\VTK\VTK-dev\bin\Wrapping\Python\vtk\vtkCommonCore.py", line 1, in <module>
>     from vtkCommonCorePython import *
> ImportError: No module named vtkCommonCorePython
> 
> I have turned the VTK_WRAP_PYTHON on and set the environment variable PYTHONPPATH with BIN_PATH/Wrapping/Python.
> 
> Does anyone have any idea about that? Thank you very much!
> 
> Best,
> Lin
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> 
> Search the list archives at: http://markmail.org/search/?q=vtkusers
> 
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers



More information about the vtkusers mailing list