K
K
kapit2019-04-17 01:23:37
Python
kapit, 2019-04-17 01:23:37

How to overcome the qt.qpa.plugin error when running a script with PyQt5?

Always installed pyqt with pip install pyqt5. Everything worked.
Today I did everything as usual, and when I run scripts containing PyQt, I get the following.

qt.qpa.plugin: Could not find the Qt platform plugin "windows" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

In this case, the module itself is imported. For example, in the code below it gives an error on line 4.
import sys
from PyQt5.QtWidgets import QApplication, QWidget
if __name__ == '__main__':
  app = QApplication(sys.argv)
  w = QWidget()
  w.resize(250, 150)
  w.move(300, 300)
  w.setWindowTitle('Simple')
  w.show()
  sys.exit(app.exec_())

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Lazarev, 2019-04-17
@kapit

There may be a conflict between the versions of the Python interpreter and PyQt5.
You can try to solve it by reinstalling pip install PyQt5==<версия> --force-reinstalland substitute the latest working version of PyQt5 instead of the version.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question