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
Related
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.
I want to deploy an executable (.exe) from my python2.7 project with everything included. I have seen pyinstaller and py2exe but the problem is that my project uses a lot of third-party packages that are not supported by default. What is the best choice for such cases? Is there any other distribution packager that could be used?
Thank you
The executable creation packages should be able to grab 3rd party packages if they're installed. Sometimes you have to specify what to include if the library abuses Python's importing system or it's not a "pure Python" package. For example, I would sometimes have to specifically include lxml to get py2exe to pick it up properly.
The py2exe project for Python 2 hasn't been updated in quite a long time, so I would certainly recommend one of the alternatives: PyInstaller, cx_freeze or bb_freeze.
I have only seen issues with MSVCP90.dll when using non pure Python packages, such as wxPython. Normally you can add that in your setup.py to include it. If that doesn't work, then you could also add it using an installer utility like NSIS. Or you may just have to state in your README that your app depends on Microsoft's C++ redistributable and include a link to it.
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.
I have a simple application. When I compile it in .NET I can just distribute the .dll or .exe without having an installer.
But how do I do this with Python? For example we have machine without the Python interpreter or with the Python interpreter but without 3rd party libraries.
You have a couple of options:
Provide an installer for Python. Once they've installed Python, they're good. They've already had the .NET runtime installed - this is really no different (except Microsoft didn't embed Python into their OS)
Use Portable Python. You can actually build your own version (though I've never done it so I have no clue how hard it would be).
Use cxFreeze or py2exe. This packages the python interpreter up along with your source so it looks like just one .exe but actually contains more
Use IronPython this way or distribute it in some other fashion.
If you don't require access to the local machine, use Flask or some other Python framework/microframework and host the app on the web using something like Heroku's free tier.
There might be some other options as well, but those are probably the most common.
Use Py2Exe. It makes a .exe file out of your script, including the interpreter and required libraries. It's going to be bigger than your script though because of the interpreter.
I'm new to python and I'm writing my first program. I would like after I finish to be able to run the program from the source code on a windows or mac machine. My program has dependencies on 3rd party modules.
I read about virtualenv but I don't think it helps me because it says it's not relocatable and it's not cross-platform (see Making Environments Relocatable http://pypi.python.org/pypi/virtualenv).
The best scenario is to install the 3rd party modules locally in my project, aka xcopy installation.
I will be really surprised if python doesn't support this easily especially since it promotes simplicity and frictionless programming.
You can do what you want, you just have to make sure that the directory containing your third-party modules is on the python path.
There's no requirement to install modules system-wide.
Note, while packaging your whole app with py2exe may not be an option, you can use it to make a simple launcher environment. You make a script with imports your module/package/whatever and launches the main() entry-point. Package this with py2exe but keep your application code outside this, as python code or an egg. I do something similar where I read a .pth text file to learn what paths to add to the sys.path in order to import my application code.
Simply, that's generally not how python works. Modules are installed site-wide and used that way. Are you familiar with pip and/or easy_install? Those + pypi let you automatically install dependencies no matter what you need.
If you want to create a standalone executable typically you'd use py2exe, py2app or something like that. Then you would have no dependencies on python at all.
I also found about zc.buildout that can be used to include dependencies in an automatic way.