Python 3.6.x PyInstaller gives error "No module named 'PyQt5.sip'"

Joe Doe picture Joe Doe · Jul 13, 2018 · Viewed 15.3k times · Source

I developed a few programs that runs well on Python 3.5.4, but because of some errors about win32 made me go to Python 3.6.4, but when I build my project with pyinstaller, I get:

C:\Users\User\Desktop\dist\mycommentator>mycommentator.exe
Traceback (most recent call last):
  File "mycommentator.py", line 6, in <module>
  File "c:\users\user\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 714, in load_module
    module = loader.load_module(fullname)
ModuleNotFoundError: No module named 'PyQt5.sip'
[1532] Failed to execute script mycommentator

I tried to reinstall python, so I installed Python 3.6.4/Python 3.6.5, that error happened to me too. No matter what code in PyQt5 I build, every time this error.

I also tried to move sip.pyd to the project folder, but error still happens. I also tried pip install --upgrade sip, that didn't help. I also tried to install the develop version of the pyinstaller, that didn't help too.

Answer

johnashu picture johnashu · Jul 13, 2018

I had the same issue which is apparently a known bug due to sip now being installed separately.

https://github.com/pyinstaller/pyinstaller/issues/3630

Upon creating the installer I added the line:

--hidden-import PyQt5.sip

This worked no problem.