Python 3.6.x PyInstaller 给出错误“No module named 'PyQt5.sip'"

Python 3.6.x PyInstaller 给出错误“No module named 'PyQt5.sip'

问题描述:

我开发了一些在 Python 3.5.4 上运行良好的程序,但由于有关 win32 的一些错误使我转到了 Python 3.6.4,但是当我使用 pyinstaller 构建我的项目时,我得到:

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

我尝试重新安装 python,所以我安装了 Python 3.6.4/Python 3.6.5,这个错误也发生在我身上.无论我在 PyQt5 中构建什么代码,每次都会出现此错误.

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.

我也尝试将 sip.pyd 移动到项目文件夹,但错误仍然发生.我还尝试了 pip install --upgrade sip,但没有帮助.我还尝试安装 pyinstaller 的开发版本,但也没有用.

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.

我遇到了同样的问题,这显然是一个已知错误,因为 sip 现在单独安装.

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

这没问题.