I am trying to plot things with pyplot on linux using pycharm. However, every time I try to show a plot I get the following error.
QObject::moveToThread: Current thread (0x556ba671bce0) is not the object's thread (0x556ba6a9dc30).
Cannot move to target thread (0x556ba671bce0)
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "path" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: xcb, eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl.
I tried reinstalling xcb using
sudo apt-get install libxcb-randr0-dev libxcb-xtest0-dev libxcb-xinerama0-dev libxcb-shape0-dev libxcb-xkb-dev
but it did not work.
In general, there are issues with frameworks like MatplotLib and XCB due to the back-end Matplotlib uses:
Could not find or load the Qt platform plugin "xcb"
Try to use the 'agg' back-end:
export MPLBACKEND=agg
or
matplotlib.use('agg')
I can't promise this works but whenever in doubt, just run the three " sudos ":
sudo apt update
(Updates all packages) sudo apt upgrade
(Updates the system) sudo apt autoremove
(Removes packages that are no longer used by the system) Command: sudo apt autoremove && sudo apt update && sudo apt upgrade
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.