Paraview python crashing when saving screenshot

I have installed paraviewopenfoam56 on Ubuntu 18.04. When I save a screenshot from GUI, all is good. But if I attempt to do it through python script, then paraview crashes with seg fault.

To make my point clear: this is the script I generated using stack trace for just saving a blank screenshot. The GUI method works perfectly (I have used it many times in past too).

# trace generated using paraview version 5.6.0
#
# To ensure correct image size when batch processing, please search 
# for and uncomment the line `# renderView*.ViewSize = [*,*]`

#### import the simple module from the paraview
from paraview.simple import *
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()

# get active view
renderView1 = GetActiveViewOrCreate('RenderView')
# uncomment following to set a specific view size
# renderView1.ViewSize = [851, 499]

# current camera placement for renderView1

# save screenshot
SaveScreenshot('/home/vachan/hh.png', renderView1, ImageResolution=[851, 499])

#### saving camera placements for all active views

# current camera placement for renderView1

#### uncomment the following to render all views
# RenderAllViews()
# alternatively, if you want to write images, you can use SaveScreenshot(...).

When I run this with pvpython, it crashes. This is the first time I am using a script to get a screenshot. I find this very strange. What might be causing this? And how can I possibly fix it?

Thanking in anticipation
Vachan

Please use our last release from https://www.paraview.org/download/

Hi, I have a similar problem. Trying to use SaveScreenshot() in pvbatch but I get “error: exception occurred: Segmentation fault” when running. Running Paraview 5.10.1 and cannot upgrade at the moment. Found this bug report https://www.paraview.org/Bug/view.php?id=10556 that says GetActiveView().UseOffscreenRenderingForScreenshots = 0 could be used, but it is obsolete it seems. Is there a workaround?

Solved: It works fine when running on my local machine. The issue occurred when I was trying to connect through SSH. Changed display setting to DISPLAY=:0 and now it runs smoothly.
/Martin