# Loading a plugin in pvbatch script

**URL:** https://discourse.paraview.org/t/loading-a-plugin-in-pvbatch-script/15030
**Category:** ParaView Support
**Created:** [July 10, 2024, 10:09am UTC](https://discourse.paraview.org/t/loading-a-plugin-in-pvbatch-script/15030 "2024-07-10T10:09:52Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![ftoth](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/f/76d3ee/32.png) [@ftoth](https://discourse.paraview.org/u/ftoth)
#### Post date: [July 10, 2024, 10:09am UTC](https://discourse.paraview.org/t/loading-a-plugin-in-pvbatch-script/15030/1 "2024-07-10T10:09:52Z")

</div>

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:

```auto
# 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]
#print(cfsReaderPath)

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

```

Is there a simpler solution?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [July 10, 2024, 2:16pm UTC](https://discourse.paraview.org/t/loading-a-plugin-in-pvbatch-script/15030/2 "2024-07-10T14:16:08Z")

</div>

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:

`LoadPlugin("CDIReader")`

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

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [July 10, 2024, 3:11pm UTC](https://discourse.paraview.org/t/loading-a-plugin-in-pvbatch-script/15030/3 "2024-07-10T15:11:14Z")

</div>

> [@mwestphal](#):
>
> However, 2. was recently fixed in ParaView and will be available in ParaView 5.13

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

```python
LoadDistributedPlugin("CDIReader")

```

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

---

<div class="post-metadata">

### Author: ![ftoth](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/f/76d3ee/32.png) [@ftoth](https://discourse.paraview.org/u/ftoth)
#### Post date: [July 10, 2024, 3:16pm UTC](https://discourse.paraview.org/t/loading-a-plugin-in-pvbatch-script/15030/4 "2024-07-10T15:16:29Z")

</div>

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.
