[Paraview] newbie question -- cannot run simple example

David E DeMarle dave.demarle at kitware.com
Mon Apr 30 16:21:48 EDT 2012


You are mixing VTK's python interface and ParaView's but they are not
completely interchangeable.

If you are trying to learn VTK, I suggest you compile VTK from source
with python wrapping enabled and use that directly. Although people
have used ParaView as quick way to get a vtkpython shell, the client
server  architecture of ParaView and the higher level wrapping of
objects that paraview.simple gives you is going to be a source of
confusion.

If you are trying to learn ParaView's client side python interface, I
suggest you start with the trace feature of ParaView and then look at
http://www.itk.org/Wiki/ParaView/Python_Scripting for explanations of
the things in the trace that are unfamiliar.

David E DeMarle
Kitware, Inc.
R&D Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909


On Sun, Apr 29, 2012 at 7:50 AM, newsboost <newsboost at gmail.com> wrote:
> Hi Anton,
>
> Thanks for the suggestion.
> --------
> from paraview.simple import *
> from vtk.vtkRenderingPython import * # <===== NEW LINE
> #from vtk.libvtkRenderingPython import *
>
>
> # Create a view
> view = CreateRenderView()
>
> # Initialize a new interactor
> iren = vtkRenderWindowInteractor()
> iren.SetInteractorStyle(vtkInteractorStyleTrackball())
> iren.SetRenderWindow(view.GetRenderWindow())
> iren.Initialize()
>
> # Build pipeline
> Sphere()
> Show()
> Render()
>
> # Start interaction
> iren.Start()
> --------
>
> Gives:
> ----
> $ python test.py
> Warning: In
> /build/buildd/vtk-5.8.0/Rendering/vtkInteractorStyleTrackball.cxx, line 29
> vtkInteractorStyleTrackball (0x3798210): vtkInteractorStyleTrackball will be
> deprecated in
> the next release after VTK 4.0. Please use
> vtkInteractorStyleSwitch instead.
>
>
> Traceback (most recent call last):
>  File "test.py", line 11, in <module>
>    iren.SetRenderWindow(view.GetRenderWindow())
> TypeError: argument 1: method requires a VTK object
> ----
>
> I don't have any clue about what to do - I suspect it has something to do
> with the new ubuntu 12.04. Maybe I should fill in a bug report somewhere to
> ubuntu maintainers (not expactly sure where, however)? Also the pvpython
> thing, maybe should make me fill in a bug report for ubuntu 12.04 ?
> ------
>
> $ pvpython test.py
> Error converting executable file "/usr/bin/../lib/paraview/pvpython" to real
> path: No such file or directory
> ------
>
> Thanks, although it annoys me such a simple example is not working... I
> cannot get starting learning vtk if I cannot run the simplest examples...
> :-(
>
>
>
> On 04/29/2012 01:41 PM, Anton Gladky wrote:
>>
>> Hello,
>>
>> try so:
>>
>> from vtk.vtkRenderingPython import *
>>
>> pvpython issue needs to be investigated.
>>
>> Anton
>>
>>
>> 2012/4/29 Newsboost Guy<newsboost at gmail.com>:
>>>
>>> Hi,
>>>
>>> This, I think should work:
>>>
>>> ------------------
>>> from paraview.simple import *
>>>
>>> # Create a view
>>> view = CreateRenderView()
>>>
>>> # Initialize a new interactor
>>> from vtk.libvtkRenderingPython import *
>>> iren = vtkRenderWindowInteractor()
>>> iren.SetInteractorStyle(vtkInteractorStyleTrackball())
>>> iren.SetRenderWindow(view.GetRenderWindow())
>>> iren.Initialize()
>>>
>>> # Build pipeline
>>> Sphere()
>>> Show()
>>> Render()
>>>
>>> # Start interaction
>>> iren.Start()
>>> ----------------
>>>
>>> I'm using the latest ubuntu 12.04 so I suspect maybe this isnt too
>>> good... Anyway, when I run the code I get:
>>>
>>> -----
>>> $ python test.py
>>> Traceback (most recent call last):
>>>   File "test.py", line 7, in<module>
>>>     from vtk.libvtkRenderingPython import *
>>> ImportError: No module named libvtkRenderingPython
>>> -----
>>>
>>> I then read that maybe I should better use "pvpython", this gives:
>>>
>>> --
>>> $ pvpython test.py
>>> Error converting executable file "/usr/bin/../lib/paraview/pvpython" to
>>> real path: No such file or directory
>>> --
>>>
>>>
>>> Sorry, I don't have much experience with this. It's a noob question, I
>>> know. I hope somebody knows the answer/solution. Thank you very much -
>>> I've been struggling with this (and making simple paraview python
>>> scripts) for about 10 hours. No I have to ask you guys...
>>> _______________________________________________
>>> 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


More information about the ParaView mailing list