paraview.simple Namesspace in IDE (e.g. Pycharm)

Hi all,

I use an IDE (Pycharm) to develop some postprocessing scripts with Python for Paraview. It starts to complain that it cannot resolve references, this is logical since the paraview.simple module is only available through pvpython or pvbatch as far as I know. However, it would be nice if I can import just the namespace of paraview.simple (or any other paraview module) in my IDE such that these complaints vanish (and I can use tab completion etc.) Is this possible?

Regards,
Arjan

Arjan,
You’ll need three things:1. use the same python version as paraview binary was built with. (or build paraview from source using the system python)
2. Set PYTHONPATH to point to a list of directories where paraview stores its python files
3. Set LD_LIBRARY_PATH (on Unix or equivalent on other platforms) to point to where paraview stores its DLLs.

After that you can run paraview scripts using the system python and probably with pycharm (if pycharm uses the system python).

Dan

Thanks,

I tested it for different versions of python with the expected result (it Almost works…). Getting the python versions equal is however a bit of a challenge whereas I’m not in complete control.

You could set pvpython as the interpreter used in Pycharm.
For this, rename or symlink the pvpython executable to pythonpv and add this executable as a System Interpreter in Pycharm (Settings → Project → Project Interpreter). For some reason, this only works if the executable’s name starts with python.

This actually works, except that you cannot open a console because of a missing _ssl module. Is this easy to add?

alas, no. It was explicitly removed due to request from certain cites so that the binaries pass their security muster. I am assuming you’re on Windows. You should be able to simply download the Python binaries from python.org for the appropriate version and then copy the ssl dll over.

Actually, I use Linux (Scientific Linux 7)

I got it almost to work. I’ve recompiled the correct python version (3.7.4 for Paraview 5.8.1). I’ve added the following directories to the PYTHONPATH:
<paraviewHome>/lib/python3.7/lib-dynload
<paraviewHome>/lib/python3.7/site-packages

Now I can import python.simple in Pycharm and can also use all of its functionality. I can use ExtractBlock for example and it will give me the expected results

However, in Pycharm the names of the filters are still not defined (unresolved reference), like for example ExtractBlock. If I look in the Python directory within Paraview I see that this name is not defined in any *.py file. I’ve also added several directories with libraries in the LD_LIBRARY_PATH variable to no avail:
<paraviewHome>/lib/python3.7/site-packages/vtkmodules
<paraviewHome>/lib/python3.7/lib-dynload
<paraviewHome>/lib
<paraviewHome>/lib/python3.7/site-packages/paraview/modules