PyCharm Execute Selection (Alt+Shift+E) Freezes Python Console When Displaying Matplotlib Figure
Answered
When I run the following code using PyCharm’s Execute Selection feature (Alt + Shift + E), an empty figure window is displayed. After that, it shows “Not Responding,” and the Python console freezes.
I am also including my PC information and virtual environment details below.
Could someone please help me? I really need this feature to work.
import numpy as np
import matplotlib
matplotlib.use('Qt5Agg')
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
ax.imshow(np.random.rand(512, 512))
fig.show()
Virtual Environment
├── matplotlib v3.10.8
│ ├── contourpy v1.3.3
│ │ └── numpy v2.4.0
│ ├── cycler v0.12.1
│ ├── fonttools v4.61.1
│ ├── kiwisolver v1.4.9
│ ├── numpy v2.4.0
│ ├── packaging v25.0
│ ├── pillow v12.0.0
│ ├── pyparsing v3.3.1
│ └── python-dateutil v2.9.0.post0
│ └── six v1.17.0
├── numpy v2.4.0
├── pandas v2.3.3
│ ├── numpy v2.4.0
│ ├── python-dateutil v2.9.0.post0 (*)
│ ├── pytz v2025.2
│ └── tzdata v2025.3
├── pillow v12.0.0
├── pyqt5 v5.15.11
│ ├── pyqt5-qt5 v5.15.2
│ └── pyqt5-sip v12.17.2
├── pyqt5-qt5 v5.15.2
└── scipy v1.16.3
└── numpy v2.4.0PC Environment
- Intel(R) Core(TM) Ultra 7 265KF (3.90 GHz)
- Windows 11 Home (25H2)
- PyCharm 2025.3
- Build #PY-253.28294.336, built on December 6, 2025
- Runtime version: 21.0.8+9-b1163.69 amd64 (JCEF 137.0.17)
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Please sign in to leave a comment.
Your example works for me but nonetheless, first, try adjusting to plt.show() as it properly handles the event loop and is the recommended approach.
Also, make sure to update to the latest package version of pyqt5, I'm using 5.15.18 on a uv interpreter with Python 3.13
pip install --upgrade PyQt5 PyQt5-Qt5
Hope this helps.
Thank you for your help. I'm also experiencing this problem.
https://intellij-support.jetbrains.melon playground.com/hc/en-us/community/posts/26426683534098-About-Junie