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?