I installed pyvista on my laptop with Ubuntu (version 22) by using the command pip install pyvista
. But when I import pyvista, it gives the following error.
ImportError: cannot import name 'vtkExtractEdges' from 'vtkmodules.vtkFiltersExtraction' (/home/ifti/.local/lib/python3.10/site-packages/vtkmodules/vtkFiltersExtraction.cpython-310-x86_64-linux-gnu.so)
What is wrong and how can I fix this?
Update: Python 3.10 + VTK 9.2.0(rc1) compatibility has been fixed in PyVista release 0.34.2, please update pyvista to get things to work again. Pre-0.34.2 answer below.
There is a version issue here. Firstly, you are on Python 3.10, and the only VTK version that's available on PyPI is the new 9.2.0 release candidate:
$ pip install vtk==
ERROR: Could not find a version that satisfies the requirement vtk== (from versions: 9.2.0rc1)
ERROR: No matching distribution found for vtk==
So you get the newest VTK, but the newest VTK has moved around a few things, breaking old imports. There is a recent pull request that fixes this on the PyVista side, but this was added in May, and we haven't had a PyVista release since then. There are also additional things that will break with the VTK 9.2.0 release, which still need fixing.
So there are two things you can do: either downgrade to Python 3.9, and use VTK 9.1.0 or older, or wait a bit until we publish a new PyVista release. Considering this breakage on Python 3.10 there will definitely be a new release very soon. I'll open an issue about this.