spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.33k stars 1.61k forks source link

The kernel does not stop running after a plot is created with %varexp --plot when having guiqwt/qwt installed #17703

Open abbassi95 opened 2 years ago

abbassi95 commented 2 years ago

Description

What steps will reproduce the problem?

When i make a plot of a variable using right click than plot (or the command %varexp --plot), the kernel don't stop running so i should restart the kernel or start a new one.

Versions

Dependencies

# Mandatory:
atomicwrites >=1.2.0                 :  1.4.0 (OK)
chardet >=2.0.0                      :  4.0.0 (OK)
cloudpickle >=0.5.0                  :  2.0.0 (OK)
cookiecutter >=1.6.0                 :  1.7.3 (OK)
diff_match_patch >=20181111          :  20200713 (OK)
intervaltree >=3.0.2                 :  3.1.0 (OK)
IPython >=7.31.1;<8.0.0              :  7.32.0 (OK)
jedi >=0.17.2;<0.19.0                :  0.17.2 (OK)
jellyfish >=0.7                      :  0.9.0 (OK)
jsonschema >=3.2.0                   :  4.4.0 (OK)
keyring >=17.0.0                     :  23.5.0 (OK)
nbconvert >=4.0                      :  6.4.5 (OK)
numpydoc >=0.6.0                     :  1.2.1 (OK)
paramiko >=2.4.0                     :  2.10.3 (OK)
parso >=0.7.0;<0.9.0                 :  0.7.0 (OK)
pexpect >=4.4.0                      :  4.8.0 (OK)
pickleshare >=0.4                    :  0.7.5 (OK)
psutil >=5.3                         :  5.9.0 (OK)
pygments >=2.0                       :  2.11.2 (OK)
pylint >=2.5.0                       :  2.13.4 (OK)
pyls_spyder >=0.4.0                  :  0.4.0 (OK)
pylsp >=1.4.1;<1.5.0                 :  1.4.1 (OK)
pylsp_black >=1.2.0                  :  1.2.0 (OK)
qdarkstyle >=3.0.2;<3.1.0            :  3.0.3 (OK)
qstylizer >=0.1.10                   :  0.2.1 (OK)
qtawesome >=1.0.2                    :  1.1.1 (OK)
qtconsole >=5.3.0;<5.4.0             :  5.3.0 (OK)
qtpy >=2.0.1                         :  2.0.1 (OK)
rtree >=0.9.7                        :  0.9.7 (OK)
setuptools >=49.6.0                  :  56.0.0 (OK)
sphinx >=0.6.6                       :  4.5.0 (OK)
spyder_kernels >=2.3.0;<2.4.0        :  2.3.0 (OK)
textdistance >=4.2.0                 :  4.2.2 (OK)
three_merge >=0.1.1                  :  0.1.1 (OK)
watchdog >=0.10.3                    :  1.0.2 (OK)
zmq >=17                             :  22.3.0 (OK)

# Optional:
cython >=0.21                        :  None (NOK)
matplotlib >=3.0.0                   :  3.5.1 (OK)
numpy >=1.7                          :  1.22.3 (OK)
pandas >=1.1.1                       :  1.4.2 (OK)
scipy >=0.17.0                       :  1.8.0 (OK)
sympy >=0.7.3                        :  None (NOK)

# Spyder plugins:
spyder_terminal.terminalplugin 1.2.2 :  1.2.2 (OK)
dalthviz commented 2 years ago

Hi @abbassi95 thank you for the feedback! I was unable to replicate this with the following code running from the Console:

import numpy as np
import pandas as pd
s = pd.Series([1, 3, 5, np.nan, 6, 8])
s
%varexp --plot s

imagen

Also, changing the graphics backend from inline to Qt5 worked for me:

imagen

Could you post here some example code that triggers this error for you? Also, what is backend you have selected in preferences (Preferences > IPython Console > Graphics > Graphics backend)?

Let us know!

abbassi95 commented 2 years ago

Thank you @dalthviz for your answer! Only now I found out that it is also possible to plot series (I thought it was only feasible with numpy.arrays), which is not the case for me (I have this error when I run the code from you)

github1

now, when I change the variable s to a numpy array and plot it, it works!

github2

However, the kernel does not stop running even when I close the plot window.

github3

I use the backend Qt5, but now I found out that the error is fixed when I change it to Tkinter

dalthviz commented 2 years ago

Glad you find a workaround for this @abbassi95 ! Checking the tracebacks you gave seems like the problem comes from the plot using GuiQwt/Qwt when having Qt5 selected as backend. Not totally sure if we can do something about that from Spyder but pinging @ccordoba12 just in case

ccordoba12 commented 2 years ago

I think the simplest solution is to remove support for Qwt in Spyder, so that we always use Matplotlib instead. So Qwt is a library developed by Pierre Raybaut (Spyder's original author) that is more performant than Matplotlib, but it seems it doesn't integrate well with IPython (that's why the console blocks with it). Besides, I don't know how well maintained is these days.