"ImportError: DLL load failed while importing" while using PyInstaller

TheKingElessar

I'm trying to package a PyQt5 Python app using PyInstaller.

When I package it normally, without using UPX, it works fine. When I start using UPX, though, I start running into a lot of problems. I have to use --upx-exclude "vcruntime140.dll" to keep that file from being corrupted.

Then, I run into this problem.

Traceback (most recent call last):
  File "main.py", line 3, in <module>
ImportError: DLL load failed while importing QtWidgets: The parameter is incorrect.
[26400] Failed to execute script main

Here's the beginning of main.py:

import sys
import PyQt5
from PyQt5 import QtWidgets
from PyQt5.QtGui import QIcon

I read here (similar problem, I think) that I might be having trouble with hidden imports, so I run the PyInstaller command with --hidden-import "PyQt5", then with --hidden-import "PyQt5" --hidden-import "QtWidgets". But I keep getting the same error, DLL load failed while importing QTWidgets.

The full PyInstaller command I'm using is:

pyinstaller -n "[exe name]" -i "[icon file path].ico" --upx-dir "[path to UPX]\upx-3.96-win64" --upx-exclude "vcruntime140.dll" --hidden-import "PyQt5" --hidden-import "QtWidgets" --clean main.py

What can I do to fix this error?

Andrew

I had the exact same problem earlier this week. I fixed it by disabling UPX entirely. You could go through adding more and more of the QT DLLs to the UPX exclude list to figure out which ones specifically it's corrupting if you still want to compress some of them, but for now I'm ok with just having it disabled entirely.

I tried many things - different versions of PyQT5, different versions of other libraries, none of that had any effect.

If you have a .spec file for folder based build, be sure to disable UPX in both the exe and coll sections.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Pyinstaller ImportError : DLL load failed while importing win32gui

From Dev

"ImportError: DLL load failed while importing _openmp_helpers"?

From Dev

Jupyter notebook does not launch (ImportError: DLL load failed while importing)

From Dev

Exception has occurred: ImportError DLL load failed while importing pdftotext: The specified module could not be found

From Dev

ImportError: DLL load failed while importing _psycopg: The specified module could not be found

From Dev

How to find which DLL failed in "ImportError: DLL load failed while importing" in python?

From Dev

ImportError: DLL load failed while importing pyexpat: The specified module could not be found

From Dev

How to fix "ImportError: DLL load failed" while importing win32api

From Dev

(ibm_db) ImportError: DLL load failed while importing ibm_db: The specified module could not be found

From Dev

ImportError: DLL load failed while importing QtWebKit: Le module spécifié est introuvable

From Dev

ImportError: DLL load failed while importing numpy_ops: The specified module could not be found. when importing spacy in Python

From Python

Cannot import from pywinauto: ImportError: DLL load failed while importing win32ui: A dynamic link library (DLL) initialization routine failed

From Dev

local directory while using PyInstaller

From Dev

404 Error while using Flask web app in PyInstaller executable

From Dev

NameError: name 'defaultParams' is not defined while running the .exe converted using Pyinstaller

From Dev

Add image files while building kivy executable using pyinstaller

From Dev

TypeError: expected str, bytes or os.PathLike object, not WindowsPath while converting .py using Pyinstaller

From Dev

subprocess.run isn't working while using pyinstaller with --noconsole --onefile

From Dev

Python Script not updating file contents while using a pyinstaller version of the script on a machine without python installed

From Dev

importError with pyinstaller using Twisted

From Dev

Trouble using PyInstaller in Ubuntu

From Dev

Using --onefile with a .spec in PyInstaller

From Dev

Error using PyInstaller

From Dev

Using OpenCV with PyInstaller

From Dev

Error message using pyinstaller

From Dev

How to get python console logs on my tkinter window instead of a CMD window while executing an exe file created using pyinstaller

From Dev

exe file not found while compiled with pyinstaller

From Dev

Error while executing pyinstaller executable file

From Dev

I am getting an error while installing pyinstaller

Related Related

  1. 1

    Pyinstaller ImportError : DLL load failed while importing win32gui

  2. 2

    "ImportError: DLL load failed while importing _openmp_helpers"?

  3. 3

    Jupyter notebook does not launch (ImportError: DLL load failed while importing)

  4. 4

    Exception has occurred: ImportError DLL load failed while importing pdftotext: The specified module could not be found

  5. 5

    ImportError: DLL load failed while importing _psycopg: The specified module could not be found

  6. 6

    How to find which DLL failed in "ImportError: DLL load failed while importing" in python?

  7. 7

    ImportError: DLL load failed while importing pyexpat: The specified module could not be found

  8. 8

    How to fix "ImportError: DLL load failed" while importing win32api

  9. 9

    (ibm_db) ImportError: DLL load failed while importing ibm_db: The specified module could not be found

  10. 10

    ImportError: DLL load failed while importing QtWebKit: Le module spécifié est introuvable

  11. 11

    ImportError: DLL load failed while importing numpy_ops: The specified module could not be found. when importing spacy in Python

  12. 12

    Cannot import from pywinauto: ImportError: DLL load failed while importing win32ui: A dynamic link library (DLL) initialization routine failed

  13. 13

    local directory while using PyInstaller

  14. 14

    404 Error while using Flask web app in PyInstaller executable

  15. 15

    NameError: name 'defaultParams' is not defined while running the .exe converted using Pyinstaller

  16. 16

    Add image files while building kivy executable using pyinstaller

  17. 17

    TypeError: expected str, bytes or os.PathLike object, not WindowsPath while converting .py using Pyinstaller

  18. 18

    subprocess.run isn't working while using pyinstaller with --noconsole --onefile

  19. 19

    Python Script not updating file contents while using a pyinstaller version of the script on a machine without python installed

  20. 20

    importError with pyinstaller using Twisted

  21. 21

    Trouble using PyInstaller in Ubuntu

  22. 22

    Using --onefile with a .spec in PyInstaller

  23. 23

    Error using PyInstaller

  24. 24

    Using OpenCV with PyInstaller

  25. 25

    Error message using pyinstaller

  26. 26

    How to get python console logs on my tkinter window instead of a CMD window while executing an exe file created using pyinstaller

  27. 27

    exe file not found while compiled with pyinstaller

  28. 28

    Error while executing pyinstaller executable file

  29. 29

    I am getting an error while installing pyinstaller

HotTag

Archive