I am trying to build my GUI application using cx_Freeze
. The setup.py
is as follows:
from cx_Freeze import setup, Executable
import
I know this is an old question, but today I faced this problem.
This is how I solved it:
Removed PyQt5 and everything that was related to it from my setup.py
('{"build_exe": {"packages":' <- this part).
After it compiled my exe.
If you run the exe and theres a missing PyQt5 module error, then from your site-packages directory
(path similar to this: d:\Python37\Lib\site-packages\PyQt5\)
copy the whole PyQt5 directory to your cx_freeze built lib directory (example: ..\build\exe.win-amd64-3.7\lib\)
Now try to run the exe and there should be no missing module error, at least related to PyQt5. If you have any other missing module problem, then just copy it from your site-packages into the lib directory. Hope it helps.
Don't capitalize PyQt5. Try pyqt5 in the setup.py file.
Try to remove the (unnecessary?) line
import PyQt5.Qt
from your setup.py
script.
EDIT after the OP removed this line:
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.
Try to re-install PyQt5
and cx_Freeze
, see potential caveats in ImportError: No module named PytQt5 and PyQt5 and QtGui module not found.
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:
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.