# pvpython incompatible with argparse

**URL:** https://discourse.paraview.org/t/pvpython-incompatible-with-argparse/5508
**Category:** ParaView Support
**Tags:** python
**Created:** [October 6, 2020, 5:05pm UTC](https://discourse.paraview.org/t/pvpython-incompatible-with-argparse/5508 "2020-10-06T17:05:03Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Naeeme.dmo](https://discourse.paraview.org/user_avatar/discourse.paraview.org/naeeme.dmo/32/4961_2.png) [@Naeeme.dmo](https://discourse.paraview.org/u/Naeeme.dmo)
#### Post date: [October 6, 2020, 5:05pm UTC](https://discourse.paraview.org/t/pvpython-incompatible-with-argparse/5508/1 "2020-10-06T17:05:03Z")

</div>

I am writing a python script which uses the argparse module and some paraview.simple functions and I am facing an odd problem.  
When the script has to exit due to lack of arguments for the parser, the terminal freezes.  
I have checked the script with python under Paraview versions 5.5 to 5.8. It works fine for Paraview 5.5 and 5.6 and does not work for the newer versions.  
I have made a simple example to reproduce this problem:

**Steps to reproduce**

- Save the following code in a python file “test.py”:

```auto
#!/usr/bin/env python

from paraview.simple import *
import argparse

if __name__ == " __main__":

    # parse command line argument
    parser = argparse.ArgumentParser(prog='PROG',description='Test')
    parser.add_argument("-f",metavar="File",required=True, type=str)
    args = vars(parser.parse_args())

```

- Run:

```auto
pvpython test.py -h

```

**Expected Output**  
The following text should be printed and the code **exit**.

```auto
usage: PROG [-h] -f File

Test

optional arguments:
  -h, --help show this help message and exit
  -f File

```

**Observed behavior**

After printing the usage message the code **does not exit** and pressing Ctrl+C will result in the following:

```auto
VisRTX 0.1.6, using devices:
 0: GeForce GTX 1660 Ti (Total: 6.2 GB, Available: 5.4 GB)
usage: PROG [-h] -f File

Test

optional arguments:
  -h, --help show this help message and exit
  -f File

^C
Loguru caught a signal: SIGINT
malloc(): unsorted double linked list corrupted

Loguru caught a signal: SIGABRT

```

My operating system is Centos 8 and my only option here is to close the terminal (Ctrl+q).

**Possible cause**

This problem does not occur if the following line in the code is commented:

```auto
from paraview.simple import *

```

so importing paraview.simple breaks the code.

---

<div class="post-metadata">

### Author: ![utkarsh.ayachit](https://discourse.paraview.org/user_avatar/discourse.paraview.org/utkarsh.ayachit/32/39_2.png) [@utkarsh.ayachit](https://discourse.paraview.org/u/utkarsh.ayachit)
#### Post date: [October 6, 2020, 5:10pm UTC](https://discourse.paraview.org/t/pvpython-incompatible-with-argparse/5508/2 "2020-10-06T17:10:05Z")

</div>

You’re most likely seeing the same issue as [here](https://gitlab.kitware.com/paraview/paraview/-/issues/19939).

ParaView 5.9 has updates to the OSPray libraries which should address this finalization issue.

You may overcome the problem in your script by deferring the `from paraview.simple import *` until after the argument parsing has happened.

---

<div class="post-metadata">

### Author: ![Naeeme.dmo](https://discourse.paraview.org/user_avatar/discourse.paraview.org/naeeme.dmo/32/4961_2.png) [@Naeeme.dmo](https://discourse.paraview.org/u/Naeeme.dmo)
#### Post date: [October 7, 2020, 2:50pm UTC](https://discourse.paraview.org/t/pvpython-incompatible-with-argparse/5508/3 "2020-10-07T14:50:34Z")

</div>

Thank you for your response.  
I will apply this workaround and wait for Paraview 5.9 then. 🙂
