Closing Matplotlib plots with pvpython throws TypeError in Paraview 5.7

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

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

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?

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

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

It seems to suggest that old_signal is returning a None.

Just following the Julia thread, they seem to have nailed it down to a Matplotlib bug.

I’ve made an MR to update matplotlib to 3.2.1 here. If it goes smoothly, it will be in 5.8.1, but I don’t think it’s worth holding it up.