1 year ago
#77173
CADV
Missing PySide2 module error using pyinstaller
I'm trying to convert a python script to an executable with pyinstaller (version 4.8). The script has a GUI made through PySide2 which seems to be where the error occurs.
I tested my issue further on the following code, which seems to work as a MRE.
from PySide2 import QtWidgets
app = QtWidgets.QApplication([])
window = QtWidgets.QWidget()
window.show()
app.exec_()
And my input to pyinstaller is
pyinstaller --onefile pyside2test.py
When I try to run the .exe, I briefly get an error message saying ModuleNotFoundError: No module named 'PySide2'
before the command prompt running the exe terminates. I can also see the following line in the warn-myfile.txt file from the build directory: missing module named PySide2
The MRE seems to throw the same error message, although it's too brief for me to properly read it before termination, and the warn-file contains the same line regarding PySide2.
In the command prompt, I see that the PySide2 hook doesn't load, and I've tried various iterations of manually adding hooks or setting explicit paths or hidden imports (which I don't think is the correct way to go, as I explicitly import submodules from PySide2 in the file):
pyinstaller --onefile --paths=C:\mydir\Anaconda3\Lib\site-packages\PyInstaller\hooks pyside2test.py
and
pyinstaller --onefile --paths=C:\mydir\Anaconda3\envs\myenv\lib\site-packages\ pyside2test.py
and
pyinstaller --onefile --additional-hooks-dir=C:\mydir\Anaconda3\Lib\site-packages\PyInstaller\hooks pyside2test.py
About my installation of PySide2: PySide2 version 5.13.2
channel conda-forge
.
Potentially relevant system info from running pyinstaller:
3709 INFO: Python: 3.8.12 (conda)
3766 INFO: Platform: Windows-10-10.0.18363-SP0
I hope this gives all the relevant information necessary for figuring out where I've gone wrong.
Thanks!
python
pyqt5
pyinstaller
pyside2
0 Answers
Your Answer