添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When starting the PyQt5app.exe produced by python setup.py build for the minimal PyQt5 sample contained in cx_Freeze,
a cx_Freeze: Python error in main script pops up with a PyQt5 ModuleNotFoundError: No module named PyQt5.sip
error.

When i add PyQt5.sip to the 'includes' in the setup file, i already get an error during the build process after calling python setup.py build :
ImportError: No module named 'PyQt5.sip' .

I can import PyQt5.sip in the same python environment that i used to call python setup.py build , therefore i don't understand why the error occurs during the build process.

Traceback for execution of PyQt5app.exe :

Traceback (most recent call last):
"C:\Users\Dereas\AppData\Local\Programs\Python38\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 74 in run module.run()
"C:\Users\Dereas\AppData\Local\Programs\Python38\lib\site-packages\cx_Freeze\initscripts\Console.py", line 36 in run exec(code, m.__dict__)
File "PyQt5app.py", line 4 in <module> from
  from PyQt5.QtWidgets import QApplication, QWidget
ModuleNotFoundError: No module named 'PyQt5.sip'

Related PR:

Python 3.8.7 x64
Windows 10 x64
python -m pip freeze :

cx-Freeze==6.5.3
importlib-metadata==3.4.0
PyQt5==5.15.2
PyQt5-sip==12.8.1
zipp==3.4.0
          

I cannot reproduce this anymore... i guess it was a problem with my environment (even though i observed it on 2 machines with minimal venvs). I noticed that sometimes it is necessary to pip uninstall PyQt5 PyQt5-sip (and PyQt5-Qt in case of PyQt5 5.15.3) when switching PyQt versions... i.e.pip install PyQt5==5.15.2followed by pip install PyQt5==5.15.3 will result in an error when trying to import PyQt5.QtCore (independent of cx_Freeze).

PyQt issues with cx_Freeze can also occur when having different PyQt5 versions installed with in the user packages folder (pip install PyQt5 --user) and in the system site packages folder (pip install PyQt5)