Can\'t run QT based GUI application bundled by pyinstaller, the console output shows it is due to an import error:
ImportError: unable to find
I comment all content of file site-packages\PyQt5\__init__.py
and install again. It works.
I use python3.5
with PyInstaller=3.5
and PyQt5=5.13.0
.The packaged exe is working on my computer, but does not work on others. The error message is:
File "anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
File "site-packages\PyQt5\__init__.py", line 41, in
File "site-packages\PyQt5\__init__.py", line 33, in find_qt
ImportError: unable to find Qt5Core.dll on PATH
So I see site-packages\PyQt5\__init__.py
(5.13.0) is:
def find_qt():
import os
path = os.environ['PATH']
dll_dir = os.path.dirname(__file__) + '\\Qt\\bin'
if os.path.isfile(dll_dir + '\\Qt5Core.dll'):
path = dll_dir + ';' + path
os.environ['PATH'] = path
else:
for dll_dir in path.split(';'):
if os.path.isfile(dll_dir + '\\Qt5Core.dll'):
break
else:
raise ImportError("unable to find Qt5Core.dll on PATH")
try:
os.add_dll_directory(dll_dir)
except AttributeError:
pass
find_qt()
del find_qt
I think PyQt5 can't find the PATH in the other computer although Qt5Core.dll
already exists in the
project directly. So I commented out the file and now it works.