PyInstaller 4.2 & PySide6

Heads up! You've already completed this tutorial.

samperturbe5108 | 2021-05-06 11:57:32 UTC | #1

Hi everyone !

Thank you Martin for you great work in this website and book !

I'm working on Python "modernization" (a.k.a. "take-my-old-soft-in-Py2.7-Qt4-to-make-it-great"). I never had troubles using PyQt5 or PySide2/6 (depending on the license we wish for the project), but I have now trouble with PyInstaller. Indeed, I made packaging for few projects (mostly with PyQt5), but I recently tried with PySide6, and it does not work. The packaging itself seems to work, but then when I run the program, I get the error:

qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Abandon (core dumped)

Do you have any idea/trick ? I already know that the support of PySide2/6 by PyInstaller is only partial (which give me the answer ...), but I guess we can find a workaround :slight_smile:

martin | 2021-04-23 13:55:51 UTC | #2

Hi @samperturbe5108 welcome to the forum!

To be honest, I wouldn't have expected you to get so far -- I didn't think PyInstaller was working yet!

The issue with the plugins folder is well known though -- I see on this issue that you can get around it by manually passing the location as a data argument to PyInstaller, e.g.

--add-data "PYTHON_DIRECTORY/Lib/site-packages/PySide6/forum/plugins;PySide6/forum/plugins/"

Replace PYTHON_DIRECTORY with the location of the Python install you're using PySide6 with. Or for PyQt6 --

--add-data "PYTHON_DIRECTORY/Lib/site-packages/PyQt6/sip.cp38-win_amd64.pyd;PyQt6/sip.pyd" --add-data "PYTHON_DIRECTORY/Lib/site-packages/PyQt6/Qt6;PyQt6/Qt6"

Can you try that out and see if it works for you?

samperturbe5108 | 2021-04-24 17:20:52 UTC | #3

Thank you Martin !

I already tried this solution, but without success. By the way for Linux/Unix, better to use ':' instead of ';' (see this issue).

I will come back to an old 'cx_freeze' for the moment I think. But definitely PyInstaller is worth trying ... and the '--onefile' option is very convenient.

Over 10,000 developers have bought Create GUI Applications with Python & Qt!
Create GUI Applications with Python & Qt6
Take a look

Downloadable ebook (PDF, ePub) & Complete Source code

Also available from Leanpub and Amazon Paperback

[[ discount.discount_pc ]]% OFF for the next [[ discount.duration ]] [[discount.description ]] with the code [[ discount.coupon_code ]]

Purchasing Power Parity

Developers in [[ country ]] get [[ discount.discount_pc ]]% OFF on all books & courses with code [[ discount.coupon_code ]]
Well done, you've finished this tutorial! Mark As Complete
[[ user.completed.length ]] completed [[ user.streak+1 ]] day streak

PyInstaller 4.2 & PySide6 was written by Martin Fitzpatrick .

Martin Fitzpatrick has been developing Python/Qt apps for 8 years. Building desktop applications to make data-analysis tools more user-friendly, Python was the obvious choice. Starting with Tk, later moving to wxWidgets and finally adopting PyQt.