TypeError when importing paraview simple

Hi,

I have recently encountered a TypeError when trying to import some modules from paraview.simple. I am trying to import these modules form an Anaconda environment with python 3.9.16. It can be reproduced as follows:

>>> import paraview.simple
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/kieran/anaconda3/envs/shapeopt/lib/python3.9/site-packages/paraview/simple.py", line 41, in <module>
    from paraview import servermanager
  File "/home/kieran/anaconda3/envs/shapeopt/lib/python3.9/site-packages/paraview/servermanager.py", line 3255, in <module>
    if not vtkInitializationHelper.Initialize(slist, ptype):
TypeError: arguments do not match any overloaded methods

I installed paraview from conda-forge, but have also tried installing from source and appending to the PYTHONPATH.

Running on Ubuntu 20.04.6.

Thanks

Edit to add: I have narrowed this down to a conflict somewhere with the vtk python package, which gets installed when I install pyvista as part of another dependency. I have found the following workaround:

  • I install all of my required packages
  • pip uninstall vtk
  • in the python interpreter/script, before importing paraview.simple, run import vtk, which will overload the vtk namespace with the vtk python package included in the ParaView distribution (in /lib/python3.9/site-packages/vtk.py).

After this, I am able to import paraview.simple as desired and retain all functionality.

Thanks for the tip!

Note that PV is really sensitive on the VTK version used, and also on the Python version. That’s why:

  • ParaView always comes with its own VTK embeded
  • The binaries come with a pvpython executable, that ensure correct versions are loaded

Using another python interpreter is always tricky …