How do I deploy a Python PyQt5 Application to an embedded Linux? - python

I've written a Python3 application which uses PyQt5 for the GUI, it runs fine on every desktop system.
Now I would like to run this on an embedded linux (specifically: Yocto BSP) which is delivered by the hardware manufacturer. Since there's no PyQt5 but a qt5 and python3 package running on the BSP, I would like to (somehow) make a standalone executable of the application. Plus I'm not experienced with writing bitbake recipes and creating a custom BSP and have not found any existing PyQt5 recipes.
What I've tried so far (and did not succeed):
Make a standalone executable with nuitka, cx-freeze, pyinstaller (compiled on a similiar arm platform)
Use pyqtdeploy to convert python into c++ source code, then compile it by using the supplied build-environment. I did a static compile of the pyqt5 and sip packages and everything compiles just fine, but make reports undefined references (linker errors) which I cannot resolve (as I'm not very familiar with c++).
Now what's the best approach to let a python/pyqt5 application run on an embedded linux system with very limited packages?

You can see the link
python-pyqt5

First you should get the meta of qt5:
https://github.com/meta-qt5/meta-qt5
Then modify the local.con and you-image.bb to make the qt5 can be compiled into the image.

Related

PyInstaller-packaged PyQt5 app uses wrong style on MacOS

I've packaged a python application written in Python 3.6 with PyQt5 using PyInstaller for MacOS. The application runs correctly, but the interface does not use a native-looking style. Running the program manually does use the correct style, and PyQt.QtWidgets.StyleFactory.keys() gives 'macintosh', 'Windows', and 'Fusion'. When running the packaged application, only 'Windows' and 'Fusion' are available. How can I package the 'macintosh' style with my application and instruct PyQt5 to use the native style?
The error seems to have been fixed in a unmerged branch of PyInstaller. More information can be found on the GitHub pull request conversation, but reinstalling PyInstaller using pip install https://github.com/bjones1/pyinstaller/archive/pyqt5_fix.zip fixed the style issue for me.

GUI apps in python 3.4

I've been looking for a GUI system for python applications for a while and have found these 2, Tkinter and PyQT. The issue I'm having is that I cannot work out whether PyQT requires the end user to have QT installed and whether Tkinter will work properly on another computer as I have read a lot about it being touchy when it comes to Tk/Tcl version.
What I'm trying to do with it is create an application for a friend so that he can keep track of his beehives more easily and I didn't think that having it in a terminal would be the way to go. Thanks.
I have worked with both in the past and from my observations:
whether PyQT requires the end user to have QT installed
Yes, it does. However you can bundle your app along with the dependencies (Python + QT) using tools like PyInstaller. You will get a single package that you can distribute to your users. They can run it without installing anything.
You can also create custom installers which install Python and QT on the target systems for you. Then the users can just run the Python script.
whether Tkinter will properly on another computer as I have read a lot
about it being touchy when it comes to Tk/Tcl version
I have never faced any issues with it since I mostly deployed my Tkinter apps to Windows and I installed the same version of Python on the target systems that I used to develop. However, there might be version conflicts on other platforms (eg. Linux/OS X).
What I'm tying to do with it is create an application for a friend so
that he can keep track of his beehives more easily
Have you thought about web based GUI? A python script running a webserver on a local machine? You can use the "webbrowser" module to open up a browser to load the url when the script is run.
There is another alternative: Kivy.

Release python executable with dependency on python bindings of a C++ library

I use the PyQt python binding of Qt C++ for creation of the GUI of my program. If I were to distribute/release the program as a simple executable, preferably for several common platforms, how should I do this the 'right' way?
Currently Qt and PyQt are installed in my environment, but I don't want any users to go through the process of installing these. I want my program to be a click-run solution. Having a hard time wrapping my head around how the Qt C++ library code and PyQt will be included locally in my project.
I am not very familiar yet with python program releases. I have noticed there isn't really much of an equivalent to .jar packages for python and it's that kind of result I'm looking for. Currently I'm using two python libraries which I place in the lib folder. The libraries are just the python sources with their own src folder. Is there any way to do the same with PyQt without having to install Qt in the users environment?
If you don't mind your source code can be viewed then cx_freeze will be the best option I think, otherwise nuitka also will be a option but this will hide everything. But remember depends on how complex your libs and the modules which you using it can be hard to achieve, but give a try :)
https://github.com/kayhayen/Nuitka
https://github.com/GreatFruitOmsk/cx_freeze

Do Frozen PyQt applications need the Qt to be installed on client machines

I am new to Qt and developing with python.
Would a python application developed using Qt framework and PyQt require the entire Qt framework to be installed on a user's machine in order to run a "exe" version of the application created with something like p2exe? Or would py2exe copy the required Qt framework components into the application that it creates?
I don't know what you mean by "frozen" but if your question is whether you can create an "exe" for a pyqt python script without installing python and pyqt on user machine then answer is yes. As with any other exe you don't need to install anything on user machine.
I have created a few application using pyqt and converted them to exe using pyinstaller-2.0 and it works fine on any machine. Same is true with py2exe.
Py2exe, when used with PyQt, will only copy the basics needed to get a Qt application to run. It won't copy the plugins that likely need. You need to take extra steps to install whatever image, platform, phonon, multimedia, etc. plugins you may need.
By basics I mean it will install the directly linked libraries from the Qt framework. Qt consists of a bunch of libraries. Some of those are linked directly into any executable using them (like the PyQt library), some of them are plugins. Py2exe will not copy those plugins, since it generally has no way of knowing which ones you may need. You need to let Py2exe know about the plugins your application requires: add them to the configuration file (setup.py).
No need for further install.
e.g. Py2exe will copy everything needed.
If you have some special requirement you may have to copy other stuff manually. In my application I copy some extra ddls, some ico files and some matplotlib files.

Python application builder/packager

I'm writing a program in python using PySide(PyQt) and I want to distribute it to friends and family when I'm finished. I have looked at other posts in stack overflow, but I can't seem to find any good ones showing an easy solution(command line or otherwise) that will create an executable for my program to be run on other computers who don't have python or Qt etc. I'm running Ubuntu right now, however I would like to be able to package for windows as well.
Edit: I wrote all the Qt interface in my python script, so the whole project is contained in the one script.
I have used PyInstaller to create executables for scripts using PyQt4 under Windows without any trouble. Though I have not used it on Linux, it claims Linux (and OSX) support as well. You may need to create your Windows binaries in a Windows system or through Wine according to the FAQ:
Can I package Windows binaries while running under Linux?
No, this
is not supported. Please use Wine for this, PyInstaller runs fine in
Wine. You may also want to have a look at this thread in the
mailinglist. In version 1.4 we had build in some support for this, but
it showed to work only half. It would require some Windows system on
another partition and would only work for pure Python programs. As
soon as you want a decent GUI (gtk, qt, wx), you would need to install
Windows libraries anyhow. So it's much easier to just use Wine.

Categories