Joe Doe
Joe Doe

Reputation: 31

PyInstaller (PyQt5 installed with pip) always gives me error import PyQt5.sip

If I install PyQt5 (Python 3.5.4) with .exe installer - it goes well in PyInstaller. If I install PyQt5 (Python 3.5.4) with pip3 install pyqt5 - it gives error in PyInstaller:

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

That happens each one of Python version. I tried: Python 3.5.4, Python 3.6.4, Python 3.6.5, no one went success. And no matter code I build with PyInstaller, I tried to build Hello World PyQt5. I tried to install Developer version of PyInstaller. I also tried to move sip.pyd to the project folder. I also tried to add --hidden-import=sip,pyqt5-sip.

I just want to know if it is related to the system, I would reinstall windows to fix it. I even ran a clear windows 7 on virtual machine, installed python 3.6.4, installed pyqt5 and pyinstaller (pip) and it still gives me error

Error

Upvotes: 1

Views: 6731

Answers (2)

Nester
Nester

Reputation: 129

I struggled with this problem for many many hours. I finally got it to work by following instructions on the doc page for pyinstaller. Simply use pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip to install the latest git version. Once I installed this version, I still got the sip warning, but the --onefile --noconsole --windowed app.py worked!

Upvotes: 1

Joe Doe
Joe Doe

Reputation: 31

I fixed it with adding PyQt5.sip to the pyinstaller param --hidden-import: pyinstaller filename.py --hidden-import=PyQt5.sip

Upvotes: 2

Related Questions