0

File: test_script.py

from PyQt5 import QtWidgets, QtCore, QtGui
pip install qtpy
pyinstaller --onedir test_script.py
cd dist/test_script
test_script.exe

Error:

Traceback (most recent call last):
  File "test_script.py", line 1, in <module>
ImportError: DLL load failed: The specified module could not be found.
[7508] Failed to execute script 'test_script' due to unhandled exception!

The problem is related to qtpy because if i uninstall qtpy with: pip uninstall qtpy and then i run pyinstaller test_script.py then the exe run with no error.

How can I solve this?

Edit: the qtpy module is requirement of qtwidgets module (this is why i was needed). Edditing qtwidgets module (replace qtpy with PyQt5, Signal with pyqtSignal and Slot with pyqtSlot) and renaming qtwidgets module to extra_qtwidgets, solve the error in my occasion.

Chris P
  • 2,059
  • 4
  • 34
  • 68
  • I don't understand. What do you mean by "the qtpy module is requirement of qtwidgets module (this is why i was needed)"? – musicamante Jul 19 '23 at 14:48
  • It's a dependency. See this: https://pypi.org/project/qtwidgets/ – Chris P Jul 19 '23 at 15:45
  • Oh, *that* "qtwidgets" (an incredibly poor naming choice for a module). Did you try to explicitly include the qtpy module in the pyinstaller dependencies? – musicamante Jul 19 '23 at 17:11
  • yes i tried --hidden-import as "qtpy" and as "QtPy" same error. – Chris P Jul 19 '23 at 17:19
  • Those widgets seem quite simple. If you don't need qtpy for anything else, wouldn't it be easier to just copy the code of the widgets you actually use and fix imports and names? – musicamante Jul 19 '23 at 17:23
  • Yes that i did, but why this error ocquers? – Chris P Jul 19 '23 at 17:25
  • No idea, as I don't use pyinstaller. It's possible that its way of fetching modules fails in some way due to the dynamical "guessing" qtpy does, so it *thinks* that a module exists but, in reality, it doesn't. Maybe you can try to search within their reports on the github repository and eventually make a report. – musicamante Jul 19 '23 at 19:59

0 Answers0