PyQT5 not loading Qt platform plugin "xcb"
Hi -
I'm on Ubuntu 20.04, PyCharm 2022..3.2 (professional edition). Python version is anaconda 3.9.12. When I try to run a PyQt5 application inside PyCharm, I receive the error message
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" 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: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.
Process finished with exit code 134 (interrupted by signal 6: SIGABRT)
A smsll application which generates this error in PyCharm is:
from PyQt5.QtWidgets import QApplication, QMainWindow
import sys
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
app = QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec_()
This application runs and completes normally when run from a terminal window, outside of PyCharm, with the same version of python. I've looked around the web and could find nothing that speaks to PyCharm directly. Thanks. Kevin
请先登录再写评论。
Do you use a local interpreter or SSH?
Have you tried reinstalling PyQt5?
Receiving the same error Pycharm Professional 2022.3.2. Was not receiving this error 5 days ago, and running the code from terminal works as expected.
Output without PyCharm (works normally)
Output with PyCharm (error):
Code:
How did you install PyCharm?
Is the issue reproducible in a new project with a new virtualenv/conda?
I wish I could offer more insight but I got it to work by uninstalling/installing PyQt5 and it's various dependents (e.g.pyqtgraph, pyqtchart, pyqt5-stubs, pyqt5-sip, pyqt5-qt5, pyqt5) using different combinations of the conda package manager and the default package manager.
For the record, I was using a local interpreter. And when I switched from anaconda Python 3.10 to the system Python 3.8 inside PyCharm, the small program I submitted here worked.
I tried reinstalling PyQt5 before submitting the report here but was using only the conda package manager. Apparently, there's magic in using both package managers.
Kevin