I'm looking to find a way to bundle a python app into stand-alone executables so my windows and mac using friends can use it without installing ugly dependencies. Looking online I've found a few utilities to help do this, including py2exe for windows and py2app for mac, as well as PyInstaller, cx-freeze, and bbfreeze. What have ya'll used and what would you recommend?
I've been building a python app with PyQt and PyQwt for the past few weeks and have had the same problem. I found py2app completely impossible to use, I kept running into so many problems constantly that I gave up. A few days later found PyInstaller which is fantastic. It understands both PyQt and PyQwt out of the box - and does a very nice job in wrapping everything into an app bundle. Haven't tried building a Windows executable with it yet though.
I found a good article at arstechnica on how to use py2exe and py2app although it's a bit old (you can probably skip the python 2.5 stuff) http://arstechnica.com/open-source/guides/2009/03/how-to-deploying-pyqt-applications-on-windows-and-mac-os-x.ars/
I would highly recommend using PyInstaller. There are a couple of tricks though you need to do for OS X since the support is currently only preminary http://diotavelli.net/PyQtWiki/PyInstallerOnMacOSX
I use py2exe to create a windows executable. The documentation is somewhat messy, but once I pulled together a working setup.py to use as a template I haven't had any problems altering it to generate any given exe. I've usually been able to find helpful information though Google searches, like when I needed to bundle in pngs for the UI to use.
Related
I have tried portable python but the latest version is 3.2.5. (need 3.6+)
I cannot install libraries on it, even the get-pip.py doesn't work.
I'm trying to figure out how to make my project portable on windows systems that do not have python installed.
Also I want the minimum possible libraries(core python modules) to keep the project as lean as possible,
I would go with cx_Freeze - multiplatform module for freezing your Python script in a way that allows you to open it on other Windows machines even if they do not have Python installed. It got very nice and clear documentation also: http://cx-freeze.readthedocs.io/en/latest/ and works a bit better on Windows machines then alternative PyInstaller from my experience (which has interesting option of one-file-package, but in many cases leads to security warnings due to some dirty hacks used to obtain that feature).
However, it may not be enough if you are using some specific modules in your app, as for example matplotlib, dash, etc modules are very hard to pack correctly with Freezer.
I have found a solution to my own question after a couple of days.
I did not want to create an executable for my project but I wanted a portable python folder so that I can add libraries to it as and when I need.
The recent version of portable python is WinPython.
I had to delete some unnecessary files out of it though.
It's size is about 77 mb after extracting
https://winpython.github.io/
https://sourceforge.net/projects/winpython/files/WinPython_3.6/3.6.5.0/WinPython64-3.6.5.0Zero.exe/download
Recently I've been developing Python code as a freelancer. I've mostly worked on social media bots, my usual way of delivering the code is as a Python script for people to run on their compilers. However, I've started to run into people that lack the technical knowledge of installing modules and running the code that way. How do I create a package like software and deliver it in a way that can be ready-to-run and users don't have to download anything extra? Thank you in advance for your feedback.
Check out py2exe. It is a wrapper that converts your script into an executable, so the user can run it without needing to install any python libraries.
Alternatives to py2exe are:
PyInstaller - the advantage of using this is that it lets you build executables in formats other than exe, if you want to make your program run on non-Windows platforms, for example.
cx_Freeze - this is also another cross-platform alternative.
One method would be (as stated in the previous answer) is to use exe converters, but that wouldn't be as effective if you target Mac and Linux users as well.
My solution is going to take you a little more time, but it will be worth it. Here goes:
Please learn Angular JS, or some other framework (I prefer Angular). Once you know that, you can easily develop a web app for your project, and add your Python to that.
The good news is, there are lots of tutorials for this, such as https://codehandbook.org/creating-a-web-app-using-angularjs-python-mongodb/ (also teaches you mongodb) Anyways, you can find other tutorials on your own.
You could of course, I guess, build it into a mobile app, but I think web app would be easier.
I've spent countless hours trying to understand this and unfortunately I haven't gotten to an answer yet. Or at least I don't think I have.
First up I should say that I am a Java Developer. I've only recently started working with Python and the build-process is a bit...odd for me.
In my mind I write an application, I compile it to run and I package it into a .jar for other people to use. Either as a library or for end-users to execute and have fun with it. (ignoring stuff like maven or gradle...)
I wrote a little CLT in python that consists of ~6 files and I wanted to distribute it. From what I could find I was supposed to write a setup.py and I found some guides on how to do that but ... to be honest I'm not even sure what that did. I could get my source code bundled into a tar.gz with some other meta data or it would create some weird files that I don't know what to do with.
Then I found PyInstaller and it worked great to package everything into a binary. However I've run into some problems trying to create a Debian package and it has made me re-assess and question the fact that there doesn't seem to be something in Python (without having to use an external tool) that lets me package/ bundle/ whatever my application into a single file to be run.
And that's something I can't get my head around. I mean...before there were tools like PyInstaller and P2Exe and what not, how did people distribute their applications? Am I expected to write a C application, somehow include the python code in there and compile that? Sorry if this seems like a stupid question but I'm really asking. I've googled around so much and spent so much time on it and haven't found a satisfactory answer so I hope someone here can help me with this! Thanks.
If you package your Python code for pip, you can include some executable scripts that start your program. I don't know how the situation was 5 years ago when this question got asked, but nowadays pip is pretty much integrated with Python, to the point that there's a standard library module to bootstrap pip in case it's missing:
https://docs.python.org/3/library/ensurepip.html
The situation is different if you want to package an application for some other package manager, like Anaconda or the package managers of various Linux distributions, or as a Windows installer. Obviously, you'll have to create a separate package for each package manager or installation technique you want to support.
Quick question... Once I build a .py app, with wx gui, etc... I can compile it with pyinstaller or cx_freeze, and send the binaries to my servers, correct?
Is this a good way to distribute a script? I am fairly new to app development cycle... I have a few python script which I would like to make public, because they make my life easier...
If you were to share some code with the rest of community, provide people the .py code, and wanted to distribute binaries as well, would you compile .py with pyinstaller and cx_freeze, or would you use some other method?
Dev environment currently is Mac OSX, and a debian domU....
Thanks!
The best solution depends on who you're releasing it to, and what license you're releasing it under.
If you're not concerned about revealing the code of the apps you're distributing, then a service like github or bitbucket is the way to go. The best way to contribute your code to a community (if you're releasing it open source) is through version control because it allows people to contribute and learn from it.
But, depending on your audience, you might need something more "user-friendly". In which case, cx_freeze and pyinstaller are perfectly acceptable solutions.
If you're distributing a package, you may want to look into setuptools
See also http://wiki.python.org/moin/DistributionUtilities and How can I distribute Python programs?
To share open source projects online, GitHub is the popular choice.
I have a wxPython application that is almost done & I would like to place it in my portfolio. I have to consider when someone attempts to run my app that they may not have Python, or wxPython, so if they just click the main script/python file its not going to run, right?
How should I distribute my app (how do you distribute ur apps) so that it can be run & also so that it could be run on the 3 major OS's (Unix, Windows, MacOSX)?
I know of py2exe for releasing under windows, but what can I use for Unix & MacOSX to compile the program? Whats the easiest way?
Use Gui2exe and compress with UPX to get unpacked size down.
For a setup file(exe) with uinstall info Inno-Setup is good.
I have use this with wxpython several times and got it to work on all windows versions.
For Gui2exe use optimize(2) - compressed(2) - Bundle files(3)
Bundle files(3) is the most stable,
Bundle files(1) make one big exe-file.
For one exe-file is better as last step to use Inno-Setup
You can use py2exe for Windows and py2app for Mac. PyInstaller works for Windows and Linux. Personally, I use GUI2Exe, which wraps all three and makes them a little easier to use. Note: I don't have a Mac, so I haven't tried it with that. You can check out my series on freezing Python here:
http://www.blog.pythonlibrary.org/2010/08/10/a-pyinstaller-tutorial-build-a-binary-series/
http://www.blog.pythonlibrary.org/2010/07/31/a-py2exe-tutorial-build-a-binary-series/
http://www.blog.pythonlibrary.org/2010/08/31/another-gui2exe-tutorial-build-a-binary-series/
There are a couple others on the blog too.
I suggest both, script for all platforms and frozen binary for lazy windows users.
To answer your latest question, you don't compile python. Python is an interpreted language, it gets compiled on the fly when run. A python frozen binary is actually the python interpreter with your script hardcoded in it. And frozen binaries are windows-only, AFAIK. Besides, Unix and MacOS (usually) come with python pre-installed.