cx_Freeze
cx_Freeze copied to clipboard
ImportError: DLL load failed while importing QtCore ?
Prerequisite
Describe the bug the exe file was created. while executed the built executable on another machine, i got this error:
ImportError: DLL load failed while importing QtCore: 找不到指定的模块。
To Reproduce build on computer A, run the built executable on computer A, B, C and D
Expected behavior the executable runs on all the computers.
Screenshots
Desktop (please complete the following information):
- Computer A : windows 10 64bit, cx_Freeze version [6.14.7] , Python version [e.g. 3.9], no error
- Computer B : windows 10 64bit, cx_Freeze version [6.14.7] , Python version [e.g. 3.9], no error
- Computer C : windows 10 64bit, no error
- Computer D : windows 11 64bit, ImportError: DLL load failed while importing QtCore
Additional context several months age, i built the executable with another version of cx_freeze(i forget the version), and it works on Computer D
Are you using include_msvcr?
build_exe_options = {'packages': [],
'includes': [],
'excludes': ['Tkinter', 'tkinter', 'PyQt4', 'numpy', 'IPython', 'scipy', 'pandas', 'matplotlib', 'PIL', 'unittest'],
'include_files': [(r'C:\Users\user\Anaconda3\Library\plugins\platforms', 'platforms'),
(r'C:\Users\user\Anaconda3\Library\bin\ucrtbase.dll', 'ucrtbase.dll'),
('conf.ini', 'conf.ini')],
'include_msvcr': True,
'silent': True
}
build_exe_options = {'packages': [],
'includes': [],
'excludes': ['Tkinter', 'tkinter', 'PyQt4', 'numpy', 'IPython', 'scipy', 'pandas', 'matplotlib', 'PIL', 'unittest'],
'include_files': [('conf.ini', 'conf.ini')],
'include_msvcr': True,
'silent': True
}
build_exe_options = {'packages': [], 'includes': [], 'excludes': ['Tkinter', 'tkinter', 'PyQt4', 'numpy', 'IPython', 'scipy', 'pandas', 'matplotlib', 'PIL', 'unittest'], 'include_files': [('conf.ini', 'conf.ini')], 'include_msvcr': True, 'silent': True }
commenting out the platforms & ucrtbase.dll will cause this error: This application failed to start because it could not find or load the Qt platform plugin "windows" in "". Reinstalling the application may fix this problem.
build env: Python 3.9.13 (main, Aug 25 2022, 23:51:50) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32 cx_Freeze.version '6.15.4'
now computer C does NOT run either. Computer C : windows 10 64bit, ImportError: DLL load failed while importing QtCore Computer D : windows 11 64bit, ImportError: DLL load failed while importing QtCore
Are you using PyQt5? I have tested pyqt in conda-forge and it works for pyqt5 sample. Can you try with the sample? Also, the first line of include_files copying platforms can be removed. Previous versions of pyqt differ from the actual. In my setup I use get_qt_plugins_paths but in your case, it will be automatic.
1)i'm using PyQt5. 2)if built on Computer A build env: Python 3.9.13 (main, Aug 25 2022, 23:51:50) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32 cx_Freeze.version '6.15.4' runs well on A&B, that's: Computer A : windows 10 64bit, cx_Freeze version [6.14.7] , Python version [e.g. 3.9], no error Computer B : windows 10 64bit, cx_Freeze version [6.14.7] , Python version [e.g. 3.9], no error Computer C : windows 10 64bit, ImportError: DLL load failed while importing QtCore Computer D : windows 11 64bit, ImportError: DLL load failed while importing QtCore
2)if built on Computer B build env: Python 3.9.13 (main, Aug 25 2022, 23:51:50) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32 cx_Freeze.version '6.15.4' runs well on A,B&C, but D: Computer A : windows 10 64bit, cx_Freeze version [6.14.7] , Python version [e.g. 3.9], no error Computer B : windows 10 64bit, cx_Freeze version [6.14.7] , Python version [e.g. 3.9], no error Computer C : windows 10 64bit, no error Computer D : windows 11 64bit, ImportError: DLL load failed while importing QtCore
On computer A and B, the pyqt is the same version? This test was with cx_Freeze sample?
There may be multiple mixed versions of the qt runtime installed in your PATH, which may cause dependency resolution errors, please check the dynamic library files in your PATH environment variables first.
I am facing the same issue. Any update/success?
I ran into this problem as well (ImportError DLL load failed while importing QtCore
) with cx_Freeze version 7.1.0. The error also pops up with the pyqt5 sample. cx_Freeze version 6.15.12 still works for me though.
@jarathomas Can you send me the build.exe folder zipped? (zip it and rename the extension to be accepted by github).
Two weeks ago, I tested the sample using the 7.1.0 dev and it worked (bellow the screen of pyqt5 sample w/ py 3.10):
Uh oh, this makes me think it is user error on my part. Apologies if this is a waste of time! Here is the zipped build.exe folder exe.win-amd64-3.10.txt
I installed everything in a virtual env using venv
. Here are the package versions:
Package Version
cx_Freeze 7.1.0 cx_Logging 3.2.0 lief 0.14.1 pip 24.0 PyQt5 5.15.10 PyQt5-Qt5 5.15.2 PyQt5-sip 12.13.0 setuptools 65.5.0 wheel 0.43.0
this makes me think it is user error on my part.
Not necessarily. It could be a system error, among others. I see that it is working in conda, but in the pip version there has been a regression since my test. I tested with cx_Freeze 7.0 and it passed. Can you check with 7.0? Then I'll try to find out what caused the regression, but I've already seen that a file stopped being copied (Qt5Core.dll).
Just tested with 7.0 and it is working. Thanks for looking into this!
Release 7.1.0-post0 is out! Documentation