File: using_python.md

package info (click to toggle)
vtk9 9.5.2%2Bdfsg4-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 206,640 kB
  • sloc: cpp: 2,340,827; ansic: 327,116; python: 114,881; yacc: 4,104; java: 3,977; sh: 3,032; xml: 2,771; perl: 2,189; lex: 1,787; javascript: 1,261; makefile: 194; objc: 153; tcl: 59
file content (66 lines) | stat: -rw-r--r-- 1,532 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Using Python

VTK is available on [PyPI](https://pypi.org/) for Windows, macOS and Linux.
```
pip install vtk
```
or in a [virtual environment](https://docs.python.org/3/library/venv.html) if you want to install the package only locally instead of system-wide

::::{tab-set}

:::{tab-item} Linux

```
python -m venv ./env
source ./env/bin/activate
pip install vtk
```
:::

:::{tab-item} macOS

```
python -m venv ./env
source ./env/bin/activate
pip install vtk
```
:::

:::{tab-item} Windows
Using `PowerShell`
```
python -m venv env
.\env\Activate.ps1
pip install vtk
```

or using `cmd.exe`
```
python -m venv env
.\env\activate.bat
pip install vtk
```
:::

::::

To verify the installation try to import vtk from an interactive python environment:

```python
>>> import vtk
>>> print(vtk.__version__)
9.2.6
```

That's it ! You may now try some of the
[tutorials](https://kitware.github.io/vtk-examples/site/Python/#tutorial),
[how to guides](https://kitware.github.io/vtk-examples/site/PythonHowTo) or
[examples](https://kitware.github.io/vtk-examples/site/Python).

If you are looking for a higher-level interface to VTK in Python, you may want
to explore using [PyVista](https://docs.pyvista.org) as it exposes VTK in a
"Pythonic" manner.

If you are running the script in a Linux/Windows machine without a display or a GPU, VTK will automatically
select an appropriate OpenGL render window class. Please learn more about how you can influence the
render window selection process in [](/advanced/runtime_settings.md#opengl)