7

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!

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
msfriese
  • 111
  • 3
  • 9
  • 1
    My solution for now is to just import something fomr QtXml so pyinstaller will know that this lib must be included as well. This is not a good solution though. If somebody know better please let me know! Example: "from PySide2.QtXml import QDomNode" – msfriese May 29 '18 at 11:09

1 Answers1

10

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)
Eruvanos
  • 670
  • 7
  • 13
  • 4
    Thanks, I simply added this to my script `from PySide2 import QtXml` and it worked fine. No command line parameters needed. – Joe DF Dec 13 '19 at 15:51