If I leave the filter's PythonPath property empty and put import sys and print sys.path, the filter gives "ImportError: No module named paraview" before getting a chance to execute the filter's script. So here's what I get if I instead set the filter's python path property to what allowed me to make it work:
Filter's PythonPath is set to: ProgrammableFilter1.PythonPath = " '/raid/usr/local/lib/paraview-3.98/site-packages'; '/raid/usr/local/lib/paraview-3.98'; '/raid/usr/local/lib/paraview-3.98/lib/python2.7'; '/raid/usr/local/lib/paraview-3.98/lib/python2.7/plat-linux2'; '/raid/usr/local/lib/paraview-3.98/lib/python2.7/lib-tk'; '/raid/usr/local/lib/paraview-3.98/lib/python2.7/lib-old'; '/raid/usr/local/lib/paraview-3.98/lib/python2.7/lib-dynload'; '/raid/usr/local/lib/paraview-3.98/lib/python2.7/site-packages'" The output of the filter's script "print sys.path": '/raid/usr/local/lib/paraview-3.98/lib/python2.7/site-packages', '/raid/usr/local/lib/paraview-3.98/lib/python2.7/lib-dynload', '/raid/usr/local/lib/paraview-3.98/lib/python2.7/lib-old', '/raid/usr/local/lib/paraview-3.98/lib/python2.7/lib-tk', '/raid/usr/local/lib/paraview-3.98/lib/python2.7/plat-linux2', '/raid/usr/local/lib/paraview-3.98/lib/python2.7', '/raid/usr/local/lib/paraview-3.98', '/raid/usr/local/lib/paraview-3.98/site-packages', '/home/utkarsh/Dashboards/MyTests/NightlyMaster/ParaViewSuperbuild-Release/paraview/src/paraview-build/lib', '/home/utkarsh/Dashboards/MyTests/NightlyMaster/ParaViewSuperbuild-Release/paraview/src/paraview-build/lib/site-packages', '/usr/bin', '/usr/lib/python2.6/site-packages/PyOpenGL-3.0.2-py2.6.egg', '/usr/lib/python2.6/site-packages/virtualenv-1.10.1-py2.6.egg', '/usr/lib/python2.6/site-packages/setuptools-1.1.6-py2.6.egg', '/usr/lib/python2.6/site-packages/ipython-1.2.0-py2.6.egg', '/usr/lib/python2.6/site-packages/pyzmq-14.0.1-py2.6-linux-x86_64.egg', '/usr/lib/python2.6/site-packages/Jinja2-2.7.2-py2.6.egg', '/usr/lib/python2.6/site-packages/Pygments-1.6-py2.6.egg', '/usr/lib/python2.6/site-packages/Sphinx-1.2.1-py2.6.egg', '/usr/lib/python2.6/site-packages/MarkupSafe-0.18-py2.6-linux-x86_64.egg', '/usr/lib/python2.6/site-packages/docutils-0.11-py2.6.egg', '/cm/local/apps/cuda/libs/current/pynvml', '/raid/home/simon/code/fm/fm_libs', '/usr/lib64/python26.zip', '/usr/lib64/python2.6', '/usr/lib64/python2.6/plat-linux2', '/usr/lib64/python2.6/lib-tk', '/usr/lib64/python2.6/lib-old', '/usr/lib64/python2.6/lib-dynload', '/usr/lib64/python2.6/site-packages', '/usr/lib64/python2.6/site-packages/PIL', '/usr/lib64/python2.6/site-packages/gtk-2.0', '/usr/lib/python2.6/site-packages' You see that the first paths output by the filter are the paths corresponding to the filter's PythonPath in reverse order. The rest is probably what you get if you leave PythonPath empty which do not include the directories related to paraview's python. Simon Quoting Utkarsh Ayachit <[email protected]>: > Just saw reset of thread -- mind putting > "import sys > print sys.path" > > in your ProgrammableFilter script and seeing what is the default path > it is ending up picking? > > On Sun, Mar 9, 2014 at 3:02 PM, Utkarsh Ayachit > <[email protected]> wrote: > > Did you call an UpdatePipeline before checking for point-data arrays? > > e.g. > > > > ProgrammableFilter1.UpdatePipeline() > > print ProgrammableFilter1.PointData.GetNumberOfArrays() > > > > > > Utkarsh > > > > On Wed, Mar 5, 2014 at 8:31 PM, Simon Couture > > <[email protected]> wrote: > >> Hi everyone, > >> > >> I am trying to use paraview from an external python program where I import > >> paraview.simple and mostly use python code generated by Paraview's trace > tool > >> to accomplish what I want. In general it works well, but in one instance I > need > >> to generate a new data array from my source/reader, and as far as I know, > the > >> programmable filter is the only way to do this (the actual PointData > arrays of > >> the sources are not directly visible/editable through the python shell). > Now > >> when I try to execute the python code that I get from trace to insert a > >> programmable filter with a given script, the PointData array that the > >> programmable filter's script is supposed to create is not created (and it > does > >> work when I create the programmable filter using the Paraview GUI). > >> > >> To be more clear, here is the python code that I run (cutting out camera > and > >> rendering commands): > >> > >> mysource = AVSUCDReader( FileNames=['/home/myfile.inp'] ) > >> > >> mysource.PointArrayStatus = [] > >> mysource.CellArrayStatus = [] > >> > >> RenderView1 = GetRenderView() > >> DataRepresentation3 = Show() > >> ProgrammableFilter1 = ProgrammableFilter() > >> DataRepresentation4 = Show() > >> ProgrammableFilter1.RequestUpdateExtentScript = '' > >> ProgrammableFilter1.PythonPath = '' > >> ProgrammableFilter1.RequestInformationScript = '' > >> ProgrammableFilter1.Script = "pdi = self.GetInput()\nnbpoints = > >> pdi.GetNumberOfPoints()\ninput_pointdata = > pdi.GetPointData().GetArray('data') > >> [... the rest of my script here]" > >> > >> After running this in either the paraview python shell or from an external > >> python program, if I do for instance: > >> > >> ProgrammableFilter1.PointData.GetNumberOfArrays() > >> > >> I get 0 meaning that no PointData array was created, whereas if the same > >> programmable filter is created in the paraview GUI, I would get 1. Please > note > >> that I am not using the Copy Arrays option of the programmable filter. > >> > >> Has anyone successfully used the programmable filter from a python script? > >> > >> _______________________________________________ > >> Powered by www.kitware.com > >> > >> Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > >> > >> Please keep messages on-topic and check the ParaView Wiki at: > http://paraview.org/Wiki/ParaView > >> > >> Follow this link to subscribe/unsubscribe: > >> http://www.paraview.org/mailman/listinfo/paraview > _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView Follow this link to subscribe/unsubscribe: http://www.paraview.org/mailman/listinfo/paraview
