Compiling pyqtgraph into a single executable on windows

107 views
Skip to first unread message

Dennis Jensen

unread,
Aug 11, 2020, 11:08:36 AM8/11/20
to pyqtgraph
The issue is basically that if I create a simple pyqtgraph program using PyQt on a windows platform the executable is not viable when done.

The initial issue was I was using multiprocessing in python and that had an interesting incompatibility with windows that requires one to add the `multiprocessing.freeze_support()` along with certain adjustments to how one handles creating the actual multi-processes that are different than outlined for how to use multiprocessing within the normal documentation for multiprocessing --- you would think they would implement this in the general guidelines as this slightly different implementation is compatible with all OS's not just Unix-ish ones

Now I noticed that pyqtgraph appears to use and or support multiprocessing or at least pyinstaller things it does -- and I am wondering if this is true and if perhaps the implementation of multiprocessing within the pyqtgraph library was done in the Unix-ish compatible only method which is why it works but then breaks when compiled within a Windows OS

Regardless I am striving to figure out how to adjust my code or get a compiler that will allow me to compile PyQt and pyqtgraph into a single executable within the Windows OS any help will be greatly appreciated

Matt Liberty

unread,
Aug 11, 2020, 11:23:51 AM8/11/20
to pyqtgraph
Hi Dennis,

As you have already found, packaging python for distribution is not straightforward.  I use pyqtgraph / PySide2 / Qt in the Joulescope UI:
https://github.com/jetperch/pyjoulescope_ui

We distribute this for Windows, macOS, and Linux, so it's a decent reference.  We spent quite a bit of time piecing this all together.  Within the project, you will find:
  • Use of MANIFEST.in to generate pyinstaller dependencies
  • Manual inclusion of binary libraries needed for each platform
  • multiprocessing with freeze support and logging support
  • pkgutil.get_data to support in place development, python installed, and packaged data retrieval
  • Inno Setup for the signed Windows installer
  • Mac dmg packaging using appdmg (not yet distributed on the mac app store)
We build using Visual Studio 2019 on Windows.  You can also just install the build tools by following the instructions on python.org.  Note that PySide2 5.14 had issues with some versions of python 3.7 & 3.8.  Pyside2 5.15 and python 3.8 are working great.

- Matt

Dennis Jensen

unread,
Aug 11, 2020, 11:34:58 AM8/11/20
to pyqt...@googlegroups.com
Thanks Matt I will look into this but I have a quick question of clarification -- does this work with PyQt5 (I would guess yes but want to be sure) -- further I am focused only on the Windows environment -- will streamlining this for only Windows be fairly straightforward?

--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/b3e04bc1-e939-4955-a2ae-eb3232c3d302o%40googlegroups.com.

Matt Liberty

unread,
Aug 11, 2020, 11:41:38 AM8/11/20
to pyqtgraph
It should just work with PyQt5, but we use PySide2 due to PyQt5's licensing.  PySide2 has a much more liberal license and is also now the official Qt python library.  If you plan on distributing your executable, you should consider the differences between the PySide2 and PyQt5 licensing terms.

If you are copy & pasting, you should not even need to remove the Mac and Linux packaging code.  They only run when building / releasing on those platforms.  The builds are NOT cross-platform.

Dennis Jensen

unread,
Aug 11, 2020, 11:50:04 AM8/11/20
to pyqt...@googlegroups.com
Hi Matt, fully aware of the issues with licensing of Qt vs PyQt vs PySide2 and are you aware that there are elements of PySide and PyQt that do not conform to their licensing parameters? Aka they both have elements, I believe that are covered by the Qt license, and that parts of PySide2 are covered by the GPL license -- so you have to be very careful which aspects of Qt you are using even when using PySide2 or PyQt5

Also again thanks for this I greatly appreciate the assist -- not sure if you all need the any assistance yourselves but I run a free online lab-like-classroom-like Discord message server for Python-Qt trying to help folks navigate the troubled waters for Python-Qt coding as there is a lot of misinformation and just bad information out there on how to use it properly.  If you would be interested or know of anyone that is just let me know and I forward you the invite link.

On Tue, Aug 11, 2020 at 10:41 AM Matt Liberty <matthew...@gmail.com> wrote:
It should just work with PyQt5, but we use PySide2 due to PyQt5's licensing.  PySide2 has a much more liberal license and is also now the official Qt python library.  If you plan on distributing your executable, you should consider the differences between the PySide2 and PyQt5 licensing terms.

If you are copy & pasting, you should not even need to remove the Mac and Linux packaging code.  They only run when building / releasing on those platforms.  The builds are NOT cross-platform.

--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+...@googlegroups.com.

Trần Anh

unread,
Aug 11, 2020, 5:01:22 PM8/11/20
to pyqtgraph
Hi Dennis,

Could you provide a detail error when you compiling PyQt5 on your Windows platform ON PYINSTALLER GITHUB?

The guys over there are absolutely amazing. I myself have no problem freezing my scripts. Well, of course, after I learn my way around pyinstaller.

Dennis Jensen

unread,
Aug 11, 2020, 5:33:38 PM8/11/20
to pyqt...@googlegroups.com
I get no error that I am aware of when I compile the code -- it simply does not run the executable -- if I remove the pyqtgraph from program it will compile and run without incident

--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+...@googlegroups.com.

Matt Liberty

unread,
Aug 11, 2020, 5:39:41 PM8/11/20
to pyqtgraph
If you haven't already, you can try configuring PyInstaller for EXE console=True.  You can then run from a command prompt and may see some debug information about the error.

Dennis Jensen

unread,
Aug 11, 2020, 5:52:52 PM8/11/20
to pyqtgraph
Well here is the installer line I run:  pyinstaller --noconsole --onefile --windowed TestPyQtGraph.py

I get the same results with or without the `--noconsole` reference

I have attached the Spec file it creates and the warn-.txt file it creates if those will help any
TestPyQtGraph.spec
warn-TestPyQtGraph.txt

Trần Anh

unread,
Aug 11, 2020, 6:34:41 PM8/11/20
to pyqt...@googlegroups.com
Ok, I will look at this problem closer when I got back from work (8am here in Australia).
In the meantime, it would be very helpful if you can compile it with --onedir instead of --onefile. More importantly, I would like to see the output of your app when you run it from console, not by double click.
I myself have done quite a bit of pyqtgraph and multithreading plus using pyinstaller. I'm not saying that it's smooth as butter but I have never occurred anything that I cannot get it to work with Pyinstaller.
Thanks & Regards
Anh Tran


--
You received this message because you are subscribed to a topic in the Google Groups "pyqtgraph" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pyqtgraph/J2gWS5MpoEA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pyqtgraph+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/8bca894d-e03a-4a18-85ef-2f8279f0232ao%40googlegroups.com.

Dennis Jensen

unread,
Aug 13, 2020, 11:50:19 AM8/13/20
to pyqt...@googlegroups.com
Hi again -- I have done the compile with --onedir ... just in case my system is missing something crucial that is not getting included ... would you like me to zip that up and send that. Not sure if you received the MUC (Minimal Usable Code) I zipped and sent to you earlier.  Please advise as I have not found any information that gives me any insights on why the script (exe) is failing to execute -- and running the executable from the command line as opposed to double clicking it gives me the same error message


You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/CA%2BJyws7q-UdEbha-3_jY7KKBkHyGYtZogBascd23j-qS_Shdog%40mail.gmail.com.

Trần Anh

unread,
Aug 14, 2020, 2:55:56 AM8/14/20
to pyqt...@googlegroups.com
Hi Dennis,
I just take a look at your zip file. I think it is a simple fix. Download the .spec file in this email, and then use the following command:
pyinstaller --onedir TestPyQtGraph.spec

Noticed that I use .spec instead of .py. Take a look at what I changed in the .spec file too (datas=[("Data\\TestData_0050.csv", "Data")]). Feel free to ask more question :). 
Thanks & Regards
Anh Tran

TestPyQtGraph.spec
Reply all
Reply to author
Forward
0 new messages