PyInstaller main.exe can't import PySide2.QtQuick
-
Hello,
I've packaged my app using Pyinstaller, and I get an error that it can't import
PySide2.QtQuick
.C:\WorkDir\Development\Source\App\dist\main>main Traceback (most recent call last): File "main.py", line 9, in <module> File "C:\Users\USER\AppData\Local\Temp\embedded.4bpi2020.zip\shibokensupport\__feature__.py", line 142, in _import ImportError: could not import module 'PySide2.QtQuick' [28752] Failed to execute script 'main' due to unhandled exception!
Does anyone has an idea why this is happening or how to resolve it?
EDIT:
The same happens when using the--onefile
option -
@Curtwagner1984 You can try the hidden import option.
--hidden-import=PySide2.QtQuick
for CLI orhiddenimports=['PySide2.QtQuick']
in the spec file. -
@Gojir4 Hi! It worked! Thank you so much!
Could you please elaborate on what it actually does? As in why Pyinstaller doesn't see this import without doing this?
-
@Curtwagner1984 Honestly I don't remember how I found this solution but I had to do the same for PySide2.Xml for one project I did few years ago.
edit: doc of pyinstaller says: Name an import not visible in the code of the script(s) so I guess that's expected to have some cases where imports are not detected by pyinstaller at build time and that's why hidden-import option is provided.
-
@Gojir4 Thank you so much for helping me solve this issue!