Search code examples
pyinstaller

Pyinstaller module not found error is occured. how to solve it?


I use PyQt5, cv2, PIL, etc..

After working pyinstaller, exe file did not inculde them.

Error name is "ModuleNotFoundError: No module named 'cv2'".(Also, PyQt5, PIL...)

Then I fixed spec file to "hiddenimports=['PyQt5', 'PIL']", But it did not working too.

My python version is 3.7.(use pycharm.) Pyinstaller is 3.5, 4.2, 5.0dev

How to solve this error?

I only used pycharm to install module.


Solution

  • I think this error accorded cuz of spec file overwriting, add hidden import as parameter when us create exe file of your script, such below

    pyinstaller project/script.py --hidden-import=PyQt5