PySide2 will not import when built with cx_freeze 6.6

224 views Asked by At

I have a program that is being built with cx_freeze 6.2. It was working great until we added a GUI and then we started getting ImportErrors after it build the EXE.

...
File "C:\Users\Engineer\anaconda3\lib\site-packages\PySide2\__init__.py", line 88, in <module>
File "C:\Users\Engineer\anaconda3\lib\site-packages\PySide2\__init__.py", line 54, in _setupQtDirectories
File "C:\Users\Engineer\anaconda3\lib\site-packages\shiboken2\__init__.py", line 27, in <module>
ImportError: DLL load failed: The specified module could not be found.
...

I have been looking for a solution for a while. Unfortunately the only ones I have found are "use Python 3.6 and cx_freeze 5.1.1" however that is not an option for me as we have a static environment and it will take a lot of effort to get approval to change the version of python. (smaller packages might have more luck)

I have tried new versions of cx_freeze (6.6) but still no luck.

Current Configuration: Python 3.7.6 PySide 5.15.0 shiboken2 5.15.0

Has anyone been able to find a solution to this, some build script hack or something that does not involve reinstalling a different version of Python?

1

There are 1 answers

0
gfdsweds On

You are missing the shiboken2.pyd file which appears in site-packages\shiboken2\shiboken2.pyd as the code is importing it:

shiboken2\__init__.py line 27:
from .shiboken2 import *

I didn't know much about cx_freeze but according to their documentation you
should use commands like --packages=shiboken2 or something else to include the submodules?