spyder-ide / spyder

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

Freezing Qt5 Window after pressing the save icon #19551

Open niki1423 opened 1 year ago

niki1423 commented 1 year ago

Issue Report Checklist

Problem Description

I'm using Spyder with the Qt5 Backend and want to save the figure out of the Qt5 Window. When i try to save it the window freezes and i have to close the iPython console and restart the kernel in spyder.

What steps reproduce the problem?

  1. Create a figure with qt5 backend
  2. Try to save it

What is the expected output? What do you see instead?

Sometimes i can see a short time the saving window, but then it disappears and the qt5 figure freezes.

Paste Traceback/Error Below (if applicable)

There is no error in terminal or ipython console

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.31.1 (OK) jedi >=0.17.2;<0.19.0 : 0.18.1 (OK) jellyfish >=0.7 : 0.9.0 (OK) jsonschema >=3.2.0 : 4.4.0 (OK) keyring >=17.0.0 : 23.4.0 (OK) nbconvert >=4.0 : 6.4.4 (OK) numpydoc >=0.6.0 : 1.4.0 (OK) parso >=0.7.0;<0.9.0 : 0.8.3 (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;<3.0 : 2.14.5 (OK) pyls_spyder >=0.4.0 : 0.4.0 (OK) pylsp >=1.5.0;<1.6.0 : 1.5.0 (OK) pylsp_black >=1.2.0 : 1.2.1 (OK) qdarkstyle >=3.0.2;<3.1.0 : 3.0.2 (OK) qstylizer >=0.1.10 : 0.1.10 (OK) qtawesome >=1.0.2 : 1.0.3 (OK) qtconsole >=5.3.2;<5.4.0 : 5.3.2 (OK) qtpy >=2.1.0 : 2.2.0 (OK) rtree >=0.9.7 : 0.9.7 (OK) setuptools >=49.6.0 : 63.4.1 (OK) sphinx >=0.6.6 : 5.0.2 (OK) spyder_kernels >=2.3.3;<2.4.0 : 2.3.3 (OK) textdistance >=4.2.0 : 4.2.1 (OK) three_merge >=0.1.1 : 0.1.1 (OK) watchdog >=0.10.3 : 2.1.6 (OK) xdg >=0.26 : 0.27 (OK) zmq >=22.1.0 : 23.2.0 (OK)

Optional:

cython >=0.21 : None (NOK) matplotlib >=3.0.0 : 3.6.0 (OK) numpy >=1.7 : 1.21.5 (OK) pandas >=1.1.1 : 1.4.1 (OK) scipy >=0.17.0 : 1.7.3 (OK) sympy >=0.7.3 : None (NOK)

ccordoba12 commented 1 year ago

Hey @niki1423, thanks for reporting. This could be a regression in Matplotlib 3.6.0, so please downgrade to 3.5.3 and try again. That should fix the problem.

sitadrost commented 1 year ago

Hi there, I have the same issue, or at least very similar: pressing the save button in a figure window makes this figure window unresponsive. I can still save and close the figure from the iPython command line though.

I'm using Matplotlib 3.4.3 (downgraded some time ago, because of some other issue), but I suspect this might be a Spyder issue: if I downgrade to Spyder 5.1.5, I can save figures without trouble.

Versions: Python 3.9.12 Spyder 5.3.3 Matplotlib 3.4.3 Qt 5.15.2 PyQt 5.15.7

Ubuntu 20.04

niki1423 commented 1 year ago

Thanks for your reply, first i downgraded matplotlib to 3.5.3 and had the same Issue as before. Downgrading also spyder to 5.1.5 fixed the issue. So for me it's also looking more like a spyder problem. Thanks!

ccordoba12 commented 1 year ago

@niki1423 and @sitadrost, thanks for checking that. We'll try to take a look at this in the coming months.

@impact27, do you have any idea about this? I thought it was fixed.

@dalthviz, could you check on Windows with the latest versions of Matplotlib 3.4, 3.5 and 3.6?

dalthviz commented 1 year ago

Checked on a Windows install with the conda-forge channel and it's working for me. I checked with matplotlib 3.4.3, 3.5.3 and 3.6.0 with this example code:


import matplotlib.pyplot as plt

fig, ax = plt.subplots()

fruits = ['apple', 'blueberry', 'cherry', 'orange']
counts = [40, 100, 30, 55]
bar_labels = ['red', 'blue', '_red', 'orange']
bar_colors = ['tab:red', 'tab:blue', 'tab:red', 'tab:orange']

ax.bar(fruits, counts, label=bar_labels, color=bar_colors)

ax.set_ylabel('fruit supply')
ax.set_title('Fruit supply by kind and color')
ax.legend(title='Fruit color')

plt.show()

Checking @niki1423 and @sitadrost seems like the are using Linux. Could it be something OS specific @ccordoba12 ?

sitadrost commented 1 year ago

Not sure if this is related, but I just tried running Spyder 5.3.3 (same system, for further details see my previous post) from a remote computer, using an SSH-VNC connection and KDE desktop, and then iPython fails to run: upon startup, it very briefly shows the usual In [1]: command prompt, but then it disappears and iPython becomes unresponsive. I couldn't find any error messages; are there log files that could be helpful here? Downgrading to Spyder 5.2.2 resolved this issue, so for now I'll stick to that, but yes, there might be some OS- or desktop-specific issues here.

bcolsen commented 1 year ago

I can reproduce this bug in 5.3.3 and 5.2.2 in with a Conda install in Ubuntu 20.04, as well as in the 5.3.3 binder environment.

* Spyder version: 5.2.2 None
* Python version: 3.9.9 64-bit
* Qt version: 5.12.9
* PyQt5 version: 5.12.3
* Operating System: Linux 5.15.0-46-generic

# 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.6.0;<8.0.0        :  7.31.1 (OK)
jedi >=0.17.2;<0.19.0         :  0.18.1 (OK)
jellyfish >=0.7               :  0.9.0 (OK)
jsonschema >=3.2.0            :  4.16.0 (OK)
keyring >=17.0.0              :  23.4.0 (OK)
nbconvert >=4.0               :  6.4.4 (OK)
numpydoc >=0.6.0              :  1.4.0 (OK)
parso >=0.7.0;<0.9.0          :  0.8.3 (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.14.5 (OK)
pyls_spyder >=0.4.0           :  0.4.0 (OK)
pylsp >=1.3.2;<1.4.0          :  1.3.3 (OK)
pylsp_black >=1.0.0           :  1.1.0 (OK)
qdarkstyle =3.0.2             :  3.0.2 (OK)
qstylizer >=0.1.10            :  0.1.10 (OK)
qtawesome >=1.0.2             :  1.0.3 (OK)
qtconsole >=5.2.1;<5.3.0      :  5.2.2 (OK)
qtpy >=1.5.0                  :  2.1.0 (OK)
rtree >=0.9.7                 :  0.9.7 (OK)
setuptools >=49.6.0           :  65.4.0 (OK)
sphinx >=0.6.6                :  5.0.2 (OK)
spyder_kernels >=2.2.1;<2.3.0 :  2.2.1 (OK)
textdistance >=4.2.0          :  4.2.1 (OK)
three_merge >=0.1.1           :  0.1.1 (OK)
watchdog >=0.10.3             :  2.1.6 (OK)
xdg >=0.26                    :  0.27 (OK)
zmq >=17                      :  23.2.0 (OK)

# Optional:
cython >=0.21                 :  0.29.32 (OK)
matplotlib >=2.0.0            :  3.5.2 (OK)
numpy >=1.7                   :  1.21.5 (OK)
pandas >=1.1.1                :  1.4.4 (OK)
scipy >=0.17.0                :  1.7.3 (OK)
sympy >=0.7.3                 :  1.10.1 (OK)

Downgrading to 5.1.5 does resolve this problem.

* Spyder version: 5.1.5 None
* Python version: 3.9.13 64-bit
* Qt version: 5.12.9
* PyQt5 version: 5.12.3
* Operating System: Linux 5.15.0-46-generic

# Mandatory:
atomicwrites >=1.2.0          :  1.4.1 (OK)
chardet >=2.0.0               :  5.0.0 (OK)
cloudpickle >=0.5.0           :  2.2.0 (OK)
cookiecutter >=1.6.0          :  2.1.1 (OK)
diff_match_patch >=20181111   :  20200713 (OK)
intervaltree >=3.0.2          :  3.0.2 (OK)
IPython >=7.6.0               :  8.6.0 (OK)
jedi >=0.17.2;<0.19.0         :  0.18.1 (OK)
jsonschema >=3.2.0            :  4.16.0 (OK)
keyring >=17.0.0              :  23.9.3 (OK)
nbconvert >=4.0               :  7.2.3 (OK)
numpydoc >=0.6.0              :  1.5.0 (OK)
parso >=0.7.0;<0.9.0          :  0.8.3 (OK)
pexpect >=4.4.0               :  4.8.0 (OK)
pickleshare >=0.4             :  0.7.5 (OK)
psutil >=5.3                  :  5.9.3 (OK)
pygments >=2.0                :  2.13.0 (OK)
pylint >=2.5.0;<2.10.0        :  2.9.6 (OK)
pyls_spyder >=0.4.0           :  0.4.0 (OK)
pylsp >=1.2.2;<1.3.0          :  1.2.4 (OK)
pylsp_black >=1.0.0           :  None (OK)
qdarkstyle =3.0.2             :  3.0.2 (OK)
qstylizer >=0.1.10            :  0.2.2 (OK)
qtawesome >=1.0.2             :  1.2.1 (OK)
qtconsole >=5.1.0             :  5.1.1 (OK)
qtpy >=1.5.0                  :  2.2.1 (OK)
rtree >=0.9.7                 :  1.0.1 (OK)
setuptools >=49.6.0           :  65.5.0 (OK)
sphinx >=0.6.6                :  5.3.0 (OK)
spyder_kernels >=2.1.1;<2.2.0 :  2.1.3 (OK)
textdistance >=4.2.0          :  4.5.0 (OK)
three_merge >=0.1.1           :  0.1.1 (OK)
watchdog >=0.10.3             :  2.1.9 (OK)
xdg >=0.26                    :  0.28 (OK)
zmq >=17                      :  24.0.1 (OK)

# Optional:
cython >=0.21                 :  0.29.32 (OK)
matplotlib >=2.0.0            :  3.6.1 (OK)
numpy >=1.7                   :  1.23.4 (OK)
pandas >=1.1.1                :  1.5.1 (OK)
scipy >=0.17.0                :  1.9.3 (OK)
sympy >=0.7.3                 :  1.11.1 (OK)

I found this bug report while I was looking at why my figures weren't updating without manually resizing the plot window. The plots are updating fine in 5.1.5 but not in 5.2.2 or newer so that might be associated with this. Edit: The plot updating is not working on qtconsole as well so plot updating is likely not related.

dalthviz commented 1 year ago

Hi @bcolsen ! Thanks for the feedback! I think QtConsole 5.4.0 was released yesterday. Could you check if the issue persist with that version too? Also, could it be related with a specific matplotlib version?

bcolsen commented 1 year ago

For this "crash on save figure" bug, I was never actually able to reproduce this bug on qtconsole. The figures saved just fine on the two versions of qtconsole I tried yesterday (5.1.1, 5.3.2) and on the latest version I tried today (5.4.0). So this bug seems to be a Spyder bug.

(As for my figure update bug, I tried the new version of qtconsole and it is fixed. So I closed that bug. Sorry for the noise here about that and thank you for your suggestion!)

sitadrost commented 1 year ago

Awesome, I just installed Spyder 5.4.0, and now all issues I reported here earlier are resolved (i.e. plot window freezes upon interaction, and Spyder won't run on KDE desktop). Thanks a million for all your hard work!