Loading a plugin in pvbatch script

I need to load the CFSReader plugin provided with ParaView in a Python script that is run via pvbatch. The script should essentially open a state file and take a screenshot. The state file needs the CFSReader to be loaded.

Apparently, the “Auto Load” options set via the “Plugin Manager” in the GUI are not respected when running pvbatch. Is this intended or a bug?

I managed to use LoadPlugin in the Python script, but since the function requires an absolute path to the CFSReader.so making the script independent of the ParaView installation is not very elegant:

# get the paraview module path and find the paraview 'lib' directory
import paraview as pv
from pathlib import Path
pvPath = Path( pv.__file__ ) # pv module path
pvlib = [p for p in pvPath.parents if p.name == "lib"][0] # pv lib directory (should be the first)
# find the CFSReader plugin which should be contained in every paraview installation
cfsReaderPath = list(pvlib.glob("**/CFSReader.so"))[0]

# load CFSReader
from paraview.simple import LoadPlugin
LoadPlugin(str(cfsReaderPath), remote=False, ns=globals())

Is there a simpler solution?

Indeed, your analysis is correct, in the sense that:

  1. the autoload mechanism is not used by pvpython at all (as it relies on Qt settings)
  2. The LoadPlugin method only accept a absolute file path with ParaView 5.12

However, 2. was recently fixed in ParaView and will be available in ParaView 5.13

You can load plugins by name instead of relying on the absolute path, eg:


You can try it with the nightly binary from https://www.paraview.org/download/?version=nightly

In ParaView 5.12 and earlier, you can load by name only with


Here, “Distributed” means plugins distributed with ParaView, not distributed in the parallel computing sense.

1 Like

Thanks a lot for the fast and helpful answers!

I can confirm that LoadDistributedPlugin("CFSReader") works in 5.12 and LoadPlugin("CFSReader", remote=False, ns=globals()) works in ParaView-5.13.0-RC1-61-g9168668730.