How to solve the unexpected pyinstaller exception "pyqt5_plugins distribution was not found"?

Question:

I wrote a window application using the PyQt5 library. After compiling by "pyinstaller" when trying to run the exe file, the following error occurs:

Error

I tried to reinstall pyqt5_plugins library, compile the program without the "–windowed" option, or remove errors from the "warn-main.txt" file, nothing helped. Has anyone encountered such a problem?

Asked By: TheQuietestHand

||

Answers:

Use

--copy-metadata pyqt5_plugins --copy-metadata qt5_tools --copy-metadata qt5_applications --hidden-import qt5_tools --collect-submodules qt5_applications --collect-submodules pyqt5_plugins

EDIT:
For me I need several copy-metadata and collect-submodules to work.

Answered By: gfdsweds

Try go to the line where latest traceback shows and check if the import statement is ok.
In my case I did

from pyqt5_plugins.examplebuttonplugin import QtGui

and when I correct it to

from PyQt5 import QtGui

It works.

Answered By: user145808