Registry / data / pyevtk

pyevtk

JSON →
library1.7.0pypypi✓ verified 87d ago

pyevtk is a Python library for exporting numerical data (like structured grids, unstructured grids, and points) into binary VTK (Visualization Toolkit) files, enabling visualization in tools like ParaView or VisIt. As of version 1.6.0, it supports various data types and has an active, albeit slow, release cadence.

pip install pyevtk
INSTALL
IMPORT
SIG · PYEVTK
P
pyevtk
datapythonv1.7.0
Install
3.5s avg
Import
269ms
Disk
89MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.7.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.258s · 89.5MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 3.5s · import 0.280s · 86MB
89MB installed
● package 89MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

gridToVTK
from pyevtk.hl import gridToVTK
from evtk.hl import gridToVTK
The `evtk` package is an alias for `pyevtk` for backward compatibility but is deprecated and will issue a warning. Always use `pyevtk`.
pointsToVTK
from pyevtk.hl import pointsToVTK
imageToVTK
from pyevtk.hl import imageToVTK

This quickstart demonstrates how to export a structured grid with both cell-centered and point-centered data to a VTK Structured Grid (.vts) file using `gridToVTK`.

import numpy as np from pyevtk.hl import gridToVTK # Define grid dimensions nx, ny, nz = 64, 64, 64 # Coordinates x = np.arange(0, nx, 1, dtype='float64') y = np.arange(0, ny, 1, dtype='float64') z = np.arange(0, nz, 1, dtype='float64') # Cell data (e.g., temperature) temp = np.random.rand(nx - 1, ny - 1, nz - 1) # Point data (e.g., pressure) press = np.random.rand(nx, ny, nz) # Export to VTK file gridToVTK( "output_grid", x, y, z, cellData={'temperature': temp}, pointData={'pressure': press} ) print("VTK file 'output_grid.vts' generated successfully.")
Debug
Known issues
deprecatedUsing `from evtk.hl import ...` is deprecated. The `evtk` package is an alias for `pyevtk` for backward compatibility but will issue a `DeprecationWarning` and may be removed in future versions.
fix
Always use `from pyevtk.hl import ...` for all imports, e.g., `from pyevtk.hl import gridToVTK`.
affects: >=1.1.2
gotchaAll input data arrays (e.g., `data`, `x`, `y`, `z` coordinates) must be NumPy arrays. Passing standard Python lists or other array-like objects will result in `TypeError` or unexpected behavior.
fix
Ensure all array inputs are `numpy.ndarray` objects. Convert them using `numpy.asarray()` if necessary.
affects: All versions
gotchaVTK files generated by `pyevtk` often assume cell-centered data for structured grids. Misinterpreting this can lead to data being shifted by half a cell when visualized in tools like ParaView if your data is node-centered.
fix
Be mindful of whether your data is node-centered or cell-centered. If your data is node-centered on an `(Nx, Ny, Nz)` grid, the data array passed to `gridToVTK` for cell data should typically have dimensions `(Nx-1, Ny-1, Nz-1)` to align correctly. Alternatively, explicitly define point data if appropriate.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'evtk'
Attempting to import from the deprecated `evtk` package, which might not be installed or available as an alias in the current environment/version.
fix
Change all imports from `evtk` to `pyevtk`, e.g., `from pyevtk.hl import gridToVTK`.
TypeError: Expected a numpy array for 'data' but got <class 'list'>
Input data (e.g., field values, coordinate arrays) was provided as a Python list or non-NumPy array.
fix
Convert the input data to a NumPy array before passing it to `pyevtk` functions, e.g., `import numpy as np; data = np.asarray(my_list)`.
ValueError: Data dimensions do not match grid dimensions.
The shape of the data array (e.g., `cellData` or `pointData`) does not correspond to the dimensions of the grid (e.g., `(nx, ny, nz)` for structured grids).
fix
Carefully check the expected dimensions for the specific VTK export function being used. For cell data on an `(nx, ny, nz)` grid, the data array should typically have shape `(nx-1, ny-1, nz-1)`. For point data, it should be `(nx, ny, nz)`.
Upgrade
Version history
1.7.0latest on PyPI · released May 28, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Resources
pyevtk — pip install pyevtk · libregistry