Using cx_freeze to combine 3 .py files into a standalone application? - python

I am building a PyQt GUI, and it has 3 files: one for the pictures, another that is the actual GUI, and another that actually starts the application.
I have tried py2exe, but since it is all written in Python 3.2 it didn't work. I am not at all familiar with cx_freeze and this project is already a week overdue, so if anyone can help me build this I would be very grateful.

Might I advise that you use PyInstaller? I have found it way better than py2exe and cx_freeze when building exe packages. It even handles egg files.

Related

How to put .py in .exe? [duplicate]

This question already has answers here:
How can I convert a .py to .exe for Python?
(8 answers)
Closed 2 years ago.
I have Python 3.6 and I did a project in .py that I would like to put in an .exe document ;
How can I do that ? I tried Py2exe but it did not worked due to my python version.
Thanks for your answers.
Traftmine
I faced this problem some times ago, after a lot of googling I found the best solution for me.
Alternatives
Py2Exe: Which is old, the last release on PyPi is on 21 October 2014.
pyInstaller: Is a nice tool, but with some problem that we will see later.
auto-py-to-exe: Use pyInstaller to build the .exe, so suffer the same problem, but has a nice GUI and is intuitive to use.
cx_Freeze: I think the best solution, because it was the only one that works in my case, it is also recommended from python
Investigation
During this time I looked on google and StackOverflow for the best solution, each time that I found something it was out-dated or not well explained/documented, so I studied the official docs.
py2exe
As first try I installed py2exe it seems the best option, also recommended from python, so, give it a try.
All goes fine during the installation process, so I decide to follow the tutorial and get my .exe.
During the step 3 of the tutorial, running setup I received an error, looking on google I found this.
I gave up with py2exe.
auto-py-to-exe && pyInstaller
I have installed auto-py-to-exe and all went good, the program open without problems so I create my .exe file, that works!
The only problem was that, the program works only on my laptop, on all the other machine where I try to execute the antivirus delete it.
Looking on google I found the github repository where I found one issue like the mine, reading it I understand that the problem is pyInstaller.
Looking on the pyInstaller repository I found one issue where one contributors tells to contact the antivirus vendor, so I gave up again.
cx_Freeze
Looking the docs it seems to be overcomplicated realize a simple .exe, so I have studied the documentation and found what I need.
Open you project folder and create inside it a setup.py file with inside:
from sys import executable
from cx_Freeze import setup, Executable
setup(name='programName', version='0.1', description='my fancy description')
Setting up this file require a little bit of study, there are multiple options to set. You can set the option to create a simple .exe or also the create a windows/mac/linux installer.
Once you have your file ready, with the options that you need, just open a shell/terminal/cmd in the directory where the setup.py file is located and execute: python setup.py build
Now in your project folder you will see a folder where inside you can find your .exe file.
You should check out PyInstaller.

PyInstaller: how to create multiple programs in one folder?

I'm developing a Python package and have about 10 demo Python scripts that show its capabilities.
I want to distribute the demo scripts with PyInstaller: create 10 exe files and put them in one folder with all libraries they depend on.
Cannot you tell me, how can it be done?
This feature is present in pyinstaller, but unfortunately it is broken in since version 3.0
This bug report states it will not be included in the 3.4 release either.
py2exe can do this. I found it a little harder to use than pyinstaller but for this application is probably right.
This has been answered in another stackoverflow question and I suggest going there for more details.

How can I convert my pygame game to an .exe

I know py2exe isn't compatible with Python 3.3(which I use) I tried using cx_freeze it worked but I need to have my files with my .exe also. I have a folder that has images that I use for my game and without them the game doesn't work. Anybody know how I can convert my 3.3 pygame with a folder to an .exe? P.S I'm on Windows 7
I figured it out
If you want to include other "data files" along with your code in the .exe, use a setup script to list all the files needed. These two links should help you: FAQs- Using Data Files and distutils setup script.
Also, another alternative is to use Qt's resource system to embed the data in your code. See these two links: The Qt Resource System and PyQT by example. (But if you're using pygame, you probably aren't also using Qt)

Including python and other files

All of the python I've written so far have been fine on my own computer, but now I'd like to send some programs to friends to have them test certain features. Suppose I wrote an application in python with wxpython. Assuming people I send code to will not have either installed, what is the best way to include both python, and the wxpython library so the other person isn't struggling to get it running? I've never had to do this at this point in my learning and would love some feedback!
Thanks.
You can create a bundle using py2exe and installer using NSIS and ship it as executable so that your friend will get the complete working executable. But mind you, this will increase the size of the file enormously and I have often found it easier to ask them to install via README.txt files.
There are lots of binary builders: py2exe, cx_freeze, bbfreeze, PyInstaller, GUI2Exe. I have a whole slew of articles on these:
http://www.blog.pythonlibrary.org/2010/08/31/another-gui2exe-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/19/a-bbfreeze-tutorial-build-a-binary-series/
http://www.blog.pythonlibrary.org/2010/08/12/a-cx_freeze-tutorial-build-a-binary-series/
http://www.blog.pythonlibrary.org/2010/08/10/a-pyinstaller-tutorial-build-a-binary-series/
Unless they are going to develop with Python too, then I don't see any reason for them to want to install a bunch of multi-megabyte installers versus your own. You can read about how to use Inno Setup to create an installer here:
http://www.blog.pythonlibrary.org/2008/08/27/packaging-wxpymail-for-distribution/

Help On Python program that can use to compile python coding into a standalone .exe file

I am currently working on a python program with the use of wxpython to make out a gui application. However, i wish to compile my application to be like a standalone application where people can just get the .exe file and run it without installing python and wxpython. I am not sure if it is possible, thus i hope that someone can give me some guidance on this. Also, if it is possible, please tell me what program should i use to accomplish that.
Thanks
You need to create a frozen binary. You can use py2exe for this purpose.
For what it's worth, if you ever need to make executables on a unix system, you can use Freeze, a utility that comes with Python.
For a nice cross-platform solution, I always recommend pyinstaller (actually, I find it better than py2exe even just for making a Windows-only executable -- it can do code signing, can seamlessly incorporate "big, hairy" libraries such as PyQt, etc;-).

Categories