cx_Freeze: ImportError: No module named 'PyQt5.Qt'

前端 未结 3 632
孤独总比滥情好
孤独总比滥情好 2021-01-20 17:57

I am trying to build my GUI application using cx_Freeze. The setup.py is as follows:

from cx_Freeze import setup, Executable
import         


        
3条回答
  •  佛祖请我去吃肉
    2021-01-20 18:28

    Try to remove the (unnecessary?) line

    import PyQt5.Qt
    

    from your setup.py script.

    EDIT after the OP removed this line:

    1. Try to remove the unnecessary os.environ statements, these are for tkinter, maybe they conflict. Remove the 3 DLLs entries in the include_files (keep only the icon). Add 'atexit' to the includes list, see the cx_Freeze PyQt5 example.

    2. Try to re-install PyQt5 and cx_Freeze, see potential caveats in ImportError: No module named PytQt5 and PyQt5 and QtGui module not found.

    3. If this still does not work, maybe there is a conflict with another package used in your application. To find out, make a minimal example using only PyQt5, such as the cx_Freeze PyQt5 example and try to freeze it. If it works, add the other packages one by one, checking the frozen application at each step.

    EDIT II:

    1. A further possibility is that you have a conflict with PyQt4 if it is or has been installed on your system. Make sure to remove any import of PyQt4 from your application and maybe add an entry excludes: ['PyQt4'] to the build_exe dictionary in your setup.py script.

提交回复
热议问题