'QtAgg figures don't display in Pycharm
I'm running a Python 3.9 venv in Pycharm, and I'm trying to do some simple plots.
My figures look alright with tkAgg, and also when running the script with QtAgg from the commandline, using the same venv. However, when I run with QtAgg through Pycharm:
- I get an empty window frame which shows whatever was behind the window when it was created.
- I can move the window and switch to fullscreen but not resize it.
- When I try to close the window, nothing happens for a while, then KDE offers to terminate the application (Matplotlib).
- if I use
fig.savefig(), it saves a picture of the graph that should have been in the window.
The installation is fairly new, and it's running on Ubuntu 20.04, on KDE. I usually use openSuSe or Manjaro with KDE, and usually prefer Spyder. This means there might be some configuration in Pycharm which I'm not aware of.
I wondered if I had forgotten to add some important python module but as I said, the figures display and work just fine when running from the commandline, using the same Python venv. I also tried installing/removing Qt5, Qt6 or PySide, but nothing changes, independent of the Qt version.
I'm not sure if this could be related, but Spyder refuses to start on the same machine, due to some error in /lib/x86_64-linux-gnu/libQt5Network.so.5 -- that's using the system-wide Python 3.8 installation which also has pyQT5 installed. I suspect the package is missing an undeclared dependency, but I'd be very surprised of both PyCharm and Spyder suffered from the same undeclared missing dependency.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
