Open Paraview GUI with python functions laoded

Dear all,

I would like to start the GUI of Paraview with some python functions loaded in memory.

Now I’m using the following command to open Paraview and execute a script (that also contains some python functions)


In this case I can automatically execute all the commands in the script (that uses its python functions) when the GUI opens, however once the script is executed, if I click the pythonShell of Paraview, it seems like the environment is initialized and that the python functions of the script don’t exists: they are not loaded.

On the other hand If I manually open Paraview and load the script using the “Run script” button , then I can use the functions in the script.

I would like to open the GUI with the previous bash command and once the script terminates I would line to use the function inside it from the phytonShell, without having to re-load the script with the button.

Is it possible?



This problem seems to be similar to the one described here:

Why the Python Shell resets at startup even if a script has run?

Is there a workaround? A way to suggest paraview to load some python functions at atartup?
A sort of:

from import *

to be always executed when paraview is opened?


This is a limitation of ParaView, it could be fixed imo.

A work around is to load your script using a xml test actually using the python shell to load it.

Hello Matheiu,

Thanks for your reply.
If I open the Paraview GUI I’m already able to load my python script and functions from the Python Shell (using the run script button).
So using this xml test is possible to open the Paraview GUI with already the functions loaded?
Can you provide a small example or suggest me how to create this xml file?


./bin/paraview --dr --test-script=/home/glow/tmp/scripts.xml

scripts.xml (428 Bytes)

in scripts.xml, point to your own python script

Thanks, it works!
Now I can find my functions loaded in the python shell.

There is another little problem. Now the Paraview GUI opens however the Python shell does not appear at startup as before. I must activate it from View/python Shell (and the functions are correctly loaded inside it).
How can I force Paraview to start with already the shell active as before?


because your are using --dr.

I tried also without the -dr option and the functions are correctly loaded but the python shell is closed at startup.

Because your close it in the script, here is a modified version that do not close it:

scripts.xml (324 Bytes)

Hi Mathieu,
This is what I needed. Now everythig woks properly.
Thanks a lot for your help!