I am trying to control Paraview interactively using IDLE. This would involve sending commands from IDLE and seeing the changes occur in Paraview. I would rather not use the
I built paraview against my system python so that I could use ipython
and other packages. I just had to set my PYTHONPATH
to point to the paraview python site packages and the LD_LIBRARY_PATH
to point to the paraview lib directory.
export PYTHONPATH=/path/to/paraview/install/lib/python2.7/site-packages
export LD_LIBRARY_PATH=/path/to/paraview/install/lib
$ ipython
Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15)
Type "copyright", "credits" or "license" for more information.
IPython 5.5.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: from paraview.simple import *
In [2]: Connect("localhost")
Out[2]: Connection (cs://localhost:11111) [2]
In [3]: Cone()
Out[3]:
In [4]: Show()
Out[4]:
In [5]: GetSources()
Out[5]: {('Cone1', '8803'): }
In [6]: GetActiveSource()
Out[6]:
Screen shot of the rendered cone from the ipython paraview client
My paraview version was built from master on Ubuntu 18.04.
The only issue I had was a missing __init__.py
file in the python site-packages/paraview/modules
directory.
In [1]: from paraview.simple import *
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
in ()
----> 1 from paraview.simple import *
/home/dustin/repos/paraview_builds/master/install/lib/python2.7/site-packages/paraview/simple.py in ()
39
40 import paraview
---> 41 from paraview import servermanager
42 import paraview._backwardscompatibilityhelper
43
/home/dustin/repos/paraview_builds/master/install/lib/python2.7/site-packages/paraview/servermanager.py in ()
54 from paraview import _backwardscompatibilityhelper as _bc
55
---> 56 from paraview.modules.vtkPVServerImplementationCore import *
57 from paraview.modules.vtkPVClientServerCoreCore import *
58 from paraview.modules.vtkPVServerManagerCore import *
ImportError: No module named modules.vtkPVServerImplementationCore
I got around this by just creating an __init__.py
file in the paraview/modules
directory:
touch /path/to/paraview/install/lib/python2.7/site-packages/paraview/modules/__init__.py