cx_Freeze icon indicating copy to clipboard operation
cx_Freeze copied to clipboard

ImportError: DLL load failed while importing QtCore ?

Open andrewchenshx opened this issue 1 year ago • 11 comments

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

andrewchenshx avatar Mar 24 '23 04:03 andrewchenshx

Are you using include_msvcr?

marcelotduarte avatar Mar 24 '23 05:03 marcelotduarte

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
                     }

andrewchenshx avatar Mar 24 '23 08:03 andrewchenshx

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
                     }

marcelotduarte avatar Mar 24 '23 14:03 marcelotduarte

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.

andrewchenshx avatar Mar 25 '23 10:03 andrewchenshx

Release 6.15.3 is out!

Have you got any success? Please give me feedback.

marcelotduarte avatar Jul 08 '23 03:07 marcelotduarte

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

andrewchenshx avatar Jul 24 '23 04:07 andrewchenshx

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.

marcelotduarte avatar Jul 24 '23 04:07 marcelotduarte

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

andrewchenshx avatar Jul 24 '23 07:07 andrewchenshx

On computer A and B, the pyqt is the same version? This test was with cx_Freeze sample?

marcelotduarte avatar Jul 24 '23 07:07 marcelotduarte

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.

SoulMelody avatar Oct 14 '23 02:10 SoulMelody

I am facing the same issue. Any update/success?

hamzaumer2 avatar Feb 09 '24 14:02 hamzaumer2

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 avatar May 30 '24 16:05 jarathomas

@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): pyqt5-0-test_pyqt5-win-amd64-3_10

marcelotduarte avatar May 30 '24 17:05 marcelotduarte

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

jarathomas avatar May 30 '24 18:05 jarathomas

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).

marcelotduarte avatar May 30 '24 22:05 marcelotduarte

Just tested with 7.0 and it is working. Thanks for looking into this!

jarathomas avatar May 31 '24 04:05 jarathomas