Paraview python script error: name 'sources' is not defined

from paraview.servermanager import *
# Creates a new built-in session and makes it the active session.
Connect()

# Creates a new render view on the active session.
renModule = CreateRenderView()

# Create a new sphere proxy on the active session and register it
# in the sources group.
sphere = sources.SphereSource(registrationGroup="sources", ThetaResolution=16, PhiResolution=32)

# Create a representation for the sphere proxy and adds it to the render
# module.
display = CreateRepresentation(sphere, renModule)

renModule.StillRender()

I get the following error when running this code NameError: name 'sources' is not defined
I’m running it using the pvpython binary (/usr/bin/pvpython)
It works when I run the code inside the paraview application’s python shell. What is the issue here?

Well, sources is not defined in your script. btw where did you find this script ? It looks like someone tried to use servermanager methods only, which is odd.

I’d rewrite it like this:

from paraview import *
# Creates a new built-in session and makes it the active session.
# Connect() Useless

# Creates a new render view on the active session.
# renModule = CreateRenderView() Useless

# Create a new sphere proxy on the active session and register it
# in the sources group.
# sphere = sources.SphereSource(registrationGroup="sources", ThetaResolution=16, PhiResolution=32)
sphere = Sphere()

# Create a representation for the sphere proxy and adds it to the render
# module.
# display = CreateRepresentation(sphere, renModule)
Show()

# renModule.StillRender()
Render()