Day048 — VTK in python

Jacky Tsang
2 min readJul 11, 2018

--

Here is the procedure I took to set up a python project using VTK.

Environment:

  • Python v3.6.4
  • PyCharm Community IDE v2018.1.4
  • Windows 10 Home v1803
  1. Create a new project in PyCharm using Virtualenv, which comes with the IDE

2. Create Cylinder.py and copy code from the example “CylinderExample”

https://lorensen.github.io/VTKExamples/site/Python/GeometricObjects/CylinderExample/

3. Open the embedded terminal and type pip install vtk to install the latest version of VTK.

right click on project and select “Open in terminal”
embedded terminal

4. After installing the package, the red line under import vtk should disappear.

underneath red line is disappeared

5. Run Cylinder.py

right click Cylinder.py and select “Run”

6. A window with a cylinder inside should pop up.

Be noted that

The VTK master branch is regularly tested with Python 2.7 and 3.4, and VTK 7 should work with 2.5, 2.6, 2.7, and 3.2+. Versions of VTK prior to 7.0 will only work with Python 2.

from https://www.vtk.org/Wiki/VTK/Python_Wrapping_FAQ

reference website:

To install specific version:

pip install vtk==8.1.0

--

--

No responses yet