Joe Doe
Joe Doe

Reputation: 187

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

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.

Upvotes: 11

Views: 20304

Answers (2)

Chris P
Chris P

Reputation: 2357

I solve this error (python3.10) by adding this code at the top of the main file:

import PyQt5.sip

before this i tried hidden import (https://github.com/pyinstaller/pyinstaller/issues/5381) with no fix :(

Upvotes: 0

johnashu
johnashu

Reputation: 2211

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.

Upvotes: 21

Related Questions