Hello, I’m getting an unexpected error in a VTK Python project.
Basically I have a class that is derived from vtkPolyData and another custom-built class with multiple inheritance.
It was working flawlessly up to VTK 9.3.1, but updating to 9.4.1 it throws an “Unexpected keyword argument” error, referring to an argument of the custom class.
I interpret it as vtkPolyData refusing to exchange kwargs with the other base class, or refusing to accept multiple inheritance in general.
Is this some new feature of 9.4.1? Because it was working with 9.3.1 and I did not change anything in my code, except upgrading from 9.3.1 to 9.4.1…
One of the changes in VTK 4.1 is that several data classes, including vtkPolyData, are automatically replaced by customizations from vtkmodules.util.data_model.
So in your own code, when you try to instantiate a vtkPolyData, you’re actually getting an instance of vtkmodules.util.data_model.PolyData. This is probably what is messing up the multiple inheritance.
To check if this is the case, try adding the following to your program before any VTK modules are loaded:
import vtkmodules
vtkmodules.MODULE_MAPPER = {}
This will disable the VTK 4.1 mechanism for auto-loading util/data_model.py.
However, if I’m not mistaken, turning off the new data_model implies loosing the Numpy access to arrays, which is the main reason to upgrade to 9.4.1 for me.
Hello, I cannot use your solution because I’m not importing the whole module but specific classes individually, and I cannot test in detail since I’m out of office, but it makes sense that multiple inheritance is the problem. I tried to use composition instead and, even if I did not manage to complete the reviewed code, I get new and more reasonable errors.
You can still import vtkpython if you’re importing classes individually. All this does is import the package-level __init__.py, it doesn’t import the package contents.