Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

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

ImportError: DLL load failed while importing QtCore ? #1851

Closed
andrewchenshx opened this issue Mar 24, 2023 · 17 comments · Fixed by #2432
Closed

ImportError: DLL load failed while importing QtCore ? #1851

andrewchenshx opened this issue Mar 24, 2023 · 17 comments · Fixed by #2432

Comments

@andrewchenshx
Copy link

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

@marcelotduarte
Copy link
Owner

marcelotduarte commented Mar 24, 2023

Are you using include_msvcr?

@andrewchenshx
Copy link
Author

andrewchenshx commented Mar 24, 2023

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
                     }

@marcelotduarte
Copy link
Owner

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
                     }

@andrewchenshx
Copy link
Author

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.

@marcelotduarte
Copy link
Owner

Release 6.15.3 is out!

Have you got any success? Please give me feedback.

@andrewchenshx
Copy link
Author

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

@marcelotduarte
Copy link
Owner

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.

@andrewchenshx
Copy link
Author

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

@marcelotduarte
Copy link
Owner

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

@SoulMelody
Copy link

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.

@hamzaumer2
Copy link

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

@jarathomas
Copy link

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.

@marcelotduarte
Copy link
Owner

@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

@jarathomas
Copy link

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

@marcelotduarte
Copy link
Owner

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

@jarathomas
Copy link

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

@marcelotduarte
Copy link
Owner

Release 7.1.0-post0 is out!
Documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants