Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating pyinstaller from my script, missing PySide2.QtXml in the result

What I did was call

pyinstaller example.py

the pyinstaller gets all the important libraries for my script. I might be worth mentioning that I am working on a Windows machine. But when i run the result it tells me:

λ .\example.exe
Traceback (most recent call last):
  File "example.py", line 6, in <module>
  File "c:\applications\anaconda\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 714, in load_module

    module = loader.load_module(fullname)
ImportError: could not import module 'PySide2.QtXml'
[7684] Failed to execute script example

So there are two questions here:

  1. I can not find a library called "PySide2.QtXml" in my python installation. So I assume the .dll has a different name? What would actually the real name of the .dll be? I found Qt5Xml.dll but I can't tell if this is the right library.

  2. Once I have my library I'd like to add it to my example.spec file. Documentation says it has to look something like this:

    binaries=[ ( '/usr/lib/libiodbc.2.dylib', 'libiodbc.dylib' ) ],
    

    But I am not sure how to apply that to my currently missing library. I assume

    binaries=[ ( 'C:\somepath\Qt5Xml.dll', 'Qt5Xml.dll' ) ],
    

    would be the way to go?

Thanks in advance!

like image 237
msfriese Avatar asked May 29 '18 08:05

msfriese


1 Answers

I faced the same issue, it looks like it is a hidden import, which you can add to your spec file or on the command line:

pyinstaller --hidden-import PySide2.QtXml example.py

or within your Spec file:

a = Analysis(['start.py'],
         pathex=['/some/path'],
         binaries=[],
         datas=[],
         hiddenimports=['PySide2.QtXml'],
         hookspath=[],
         runtime_hooks=[],
         excludes=[],
         win_no_prefer_redirects=False,
         win_private_assemblies=False,
         cipher=block_cipher,
         noarchive=False)
like image 198
Eruvanos Avatar answered Sep 18 '22 03:09

Eruvanos