# Closing Matplotlib plots with pvpython throws TypeError in Paraview 5.7

**URL:** https://discourse.paraview.org/t/closing-matplotlib-plots-with-pvpython-throws-typeerror-in-paraview-5-7/3399
**Category:** ParaView Support
**Created:** [January 24, 2020, 6:12pm UTC](https://discourse.paraview.org/t/closing-matplotlib-plots-with-pvpython-throws-typeerror-in-paraview-5-7/3399 "2020-01-24T18:12:50Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![TimJim](https://discourse.paraview.org/user_avatar/discourse.paraview.org/timjim/32/1270_2.png) [@TimJim](https://discourse.paraview.org/u/TimJim)
#### Post date: [January 24, 2020, 6:12pm UTC](https://discourse.paraview.org/t/closing-matplotlib-plots-with-pvpython-throws-typeerror-in-paraview-5-7/3399/1 "2020-01-24T18:12:50Z")

</div>

Hi, I just updated from Paraview 5.6 to 5.7. I had it configured to work with an existing conda python environment. It seems that if on opening a new Matplotlib plot along the lines of the following:

```
import matplotlib.pyplot as plt
fig, ax = plt.subplots(nrows=2, ncols=1)
plt.show()

```

- on closing the plot, a TypeError is thrown:

> Traceback (most recent call last):  
> File “”, line 1, in   
> File “/home/tjim/anaconda3/envs/sound6/lib/python3.7/site-packages/matplotlib/pyplot.py”, line 269, in show  
> return \_show(\*args, \*\*kw)  
> File “/home/tjim/anaconda3/envs/sound6/lib/python3.7/site-packages/matplotlib/cbook/deprecation.py”, line 413, in wrapper  
> return func(\*args, \*\*kwargs)  
> File “/home/tjim/anaconda3/envs/sound6/lib/python3.7/site-packages/matplotlib/backend\_bases.py”, line 3309, in show  
> cls.mainloop()  
> File “/home/tjim/anaconda3/envs/sound6/lib/python3.7/site-packages/matplotlib/backends/backend\_qt5.py”, line 1100, in mainloop  
> signal.signal(signal.SIGINT, old\_signal)  
> File “/home/tjim/anaconda3/envs/sound6/lib/python3.7/signal.py”, line 47, in signal  
> handler = \_signal.signal(\_enum\_to\_int(signalnum), \_enum\_to\_int(handler))  
> TypeError: signal handler must be signal.SIG\_IGN, signal.SIG\_DFL, or a callable object

This happens if I run it from a script (i.e. pvpython test.py) or in a pvpython interpreter. At first, I suspected the QT module and have recompiled several times with different QT configurations and environment variables but I still got the same error. To confirm that it wasn’t me messing up the compilation, I also created a fresh Python 3.7 environment pulled the latest [Conda-Forge build](https://anaconda.org/conda-forge/paraview). It still produces this error on closing plots. Can you help me diagnose the issue? It doesn’t throw this error if I run the ‘ordinary python’, as oposed to pvpython (using the same libraries, I believe).

I also tried with PV 5.8.0-RC1 and it still seems to have this problem.

Thanks and regards,  
Tim

---

<div class="post-metadata">

### Author: ![danlipsa](https://discourse.paraview.org/user_avatar/discourse.paraview.org/danlipsa/32/1563_2.png) [@danlipsa](https://discourse.paraview.org/u/danlipsa)
#### Post date: [January 24, 2020, 7:11pm UTC](https://discourse.paraview.org/t/closing-matplotlib-plots-with-pvpython-throws-typeerror-in-paraview-5-7/3399/2 "2020-01-24T19:11:59Z")

</div>

Is this on Linux? What cmake version do you use to compile ParaView?

Can you try compiling paraview with

VTK\_PYTHON\_OPTIONAL\_LINK off?

@Ben Boeckel

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [January 24, 2020, 7:25pm UTC](https://discourse.paraview.org/t/closing-matplotlib-plots-with-pvpython-throws-typeerror-in-paraview-5-7/3399/3 "2020-01-24T19:25:20Z")

</div>

> [@TimJim](#):
>
> TypeError: signal handler must be signal.SIG\_IGN, signal.SIG\_DFL, or a callable object

I don’t know how ParaView could interfere with this stack. I wonder if something else is setting up a handler and confusing it. What is `old_signal` when this happens?

---

<div class="post-metadata">

### Author: ![TimJim](https://discourse.paraview.org/user_avatar/discourse.paraview.org/timjim/32/1270_2.png) [@TimJim](https://discourse.paraview.org/u/TimJim)
#### Post date: [January 25, 2020, 6:55am UTC](https://discourse.paraview.org/t/closing-matplotlib-plots-with-pvpython-throws-typeerror-in-paraview-5-7/3399/4 "2020-01-25T06:55:00Z")

</div>

It is on CentOS 7. I tried compiling with 3.14.4 and 3.16.3, they gave the same issue.

I’ll try with VTK\_PYTHON\_OPTIONAL\_LINK off, thanks for the suggestion.

Edit: the issue is still present with VTK\_PYTHON\_OPTIONAL\_LINK set to off

---

<div class="post-metadata">

### Author: ![TimJim](https://discourse.paraview.org/user_avatar/discourse.paraview.org/timjim/32/1270_2.png) [@TimJim](https://discourse.paraview.org/u/TimJim)
#### Post date: [January 25, 2020, 7:47am UTC](https://discourse.paraview.org/t/closing-matplotlib-plots-with-pvpython-throws-typeerror-in-paraview-5-7/3399/5 "2020-01-25T07:47:06Z")

</div>

While digging for hints two days ago, I had posted in this Julia thread which seemed to have a similar issue: [https://github.com/JuliaPy/PyPlot.jl/issues/459#issuecomment-577768375](https://github.com/JuliaPy/PyPlot.jl/issues/459#issuecomment-577768375)

It seems to suggest that old\_signal is returning a None.

---

<div class="post-metadata">

### Author: ![TimJim](https://discourse.paraview.org/user_avatar/discourse.paraview.org/timjim/32/1270_2.png) [@TimJim](https://discourse.paraview.org/u/TimJim)
#### Post date: [January 25, 2020, 5:18pm UTC](https://discourse.paraview.org/t/closing-matplotlib-plots-with-pvpython-throws-typeerror-in-paraview-5-7/3399/6 "2020-01-25T17:18:30Z")

</div>

Just following the Julia thread, they seem to have nailed it down to a [Matplotlib bug](https://github.com/matplotlib/matplotlib/pull/16311).

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [March 21, 2020, 12:31am UTC](https://discourse.paraview.org/t/closing-matplotlib-plots-with-pvpython-throws-typeerror-in-paraview-5-7/3399/7 "2020-03-21T00:31:58Z")

</div>

I’ve made an MR to update matplotlib to 3.2.1 [here](https://gitlab.kitware.com/paraview/paraview-superbuild/-/merge_requests/712). If it goes smoothly, it will be in 5.8.1, but I don’t think it’s worth holding it up.
