# Paraview python crashing when saving screenshot

**URL:** https://discourse.paraview.org/t/paraview-python-crashing-when-saving-screenshot/6405
**Category:** ParaView Support
**Created:** [February 6, 2021, 2:43pm UTC](https://discourse.paraview.org/t/paraview-python-crashing-when-saving-screenshot/6405 "2021-02-06T14:43:53Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![vachan-potluri](https://discourse.paraview.org/user_avatar/discourse.paraview.org/vachan-potluri/32/2919_2.png) [@vachan-potluri](https://discourse.paraview.org/u/vachan-potluri)
#### Post date: [February 6, 2021, 2:43pm UTC](https://discourse.paraview.org/t/paraview-python-crashing-when-saving-screenshot/6405/1 "2021-02-06T14:43:53Z")

</div>

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).

```auto
# 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

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [February 6, 2021, 3:01pm UTC](https://discourse.paraview.org/t/paraview-python-crashing-when-saving-screenshot/6405/2 "2021-02-06T15:01:07Z")

</div>

Please use our last release from [https://www.paraview.org/download/](https://www.paraview.org/download/)

---

<div class="post-metadata">

### Author: ![marles](https://discourse.paraview.org/user_avatar/discourse.paraview.org/marles/32/11725_2.png) [@marles](https://discourse.paraview.org/u/marles)
#### Post date: [May 31, 2023, 11:13am UTC](https://discourse.paraview.org/t/paraview-python-crashing-when-saving-screenshot/6405/4 "2023-05-31T11:13:15Z")

</div>

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](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
