PyInstaller: how to create multiple programs in one folder? - python

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.

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.

py2exe difficulties [duplicate]

This question already has answers here:
a good python to exe compiler? [closed]
(3 answers)
Closed 9 years ago.
With some useful answers of my previous question (See below), I decided to give py2exe another try.
I tried the tutorial from py2exe.org (http://www.py2exe.org/index.cgi/Tutorial), but got an error at step 3. I did 1 and 2 exactly as told, and put both files (hello.py and setup.py) in my main folder where I installed python in: D:\Programs\Python.
When running the 'code' form step 3 I got the following error, totally on the bottom of the output:
"ImportError: DLL load failed: %1 is not a valid Win32-application.*"
I've got a screenshot of the entire output, but I don't know where to upload it.
Extra information:
I have 64bit Windows 7 (profesional) and Python 2.7.3 (first I had 3.3.0, but downgraded because of some reasons). It is not a big problem for me to change to another version. I downloaded py2exe 0.6.9.
Note: I couldn't choose between py2exe for 32- or 64bit. I guess then a error should show up earlier, but it might be handy to know.
*I literally translated the last part from Dutch, so it can be slightly different then English pc's.
Previous question:
What is the easiest .py to .exe converter?
I've tried a few converters, of which cx_Freeze and py2exe. Using cx_Freeze was too complicated (I couldn't find a good tutorial) and py2exe gave some errors. Before I'm going to try to understand one of these two or try another one, I want some input which converter you think is the best, and I need a good tutorial.
I have barely experience with cmd, and am quite a newbie if it comes to programming/python, so I am looking for the easiest-to-use converter.
If you say I really need some cmd experience, please direct me to a cmd tutorial/course.
you can use GUI2exe that's the easiest way im my opinion !
You wont learn much about the converter's but it gets the job done without any problems.
ps. GUI2exe isnt a converter , its a gui to use the converters!
What kind of erros does py2exe give you? That is what I use and it works like a charm for me.
I've used py2exe previously. I assume you've looked at the tutorial on the py2exe project page?
There is also a good one available on the Python Library page.
I used py2exe for complicated Python/Qt/PyQt applications. The biggest thing you'll need to know about that is that the MSVCP90.dll file is needed. You can get that from Microsoft. You'll then need to copy it and the other files mentioned in it's license to the Python DLLs directory. Detailed instructions are available on the py2exe tutorial (Step 5)
Try py2exe and cx-freeze. These are the two most common ones you'll find out there. Most others are generally a derivative of cx-freeze

75 MB Helloworld with py2app !

I'm testing different languages to developp a desktop application for Mac&Windows.
I thought that Python+Wx worth a try so I wrote a simple hello world.
Then, I tried the py2app to package my application as a Mac application.
What a surprise to find that my hellworld.app weight as much as 75 MB !! (then I have an error at runtime but that's not the question)
Here is my question : is there a way to distribute a standalone wxPython application that weight less than a few MB ? (for instance, an adress book app).
(a Swing HelloWorld is around 3KB, plus around 20MB for the JRE)
Thank you
I would highly remmoend you using PyINstaller, which can be found here: link
it works like a chamr for me so far and it support most of the major libraries:
wxpython pyqt and even django (although i dont really understand the whole django support thing ;-) )
PyInstaller is a program that converts (packages) Python programs into stand-alone executables, under Windows, Linux, and Mac OS X. Its main advantages over similar tools are that PyInstaller works with any version of Python since 2.2, it builds smaller executables thanks to transparent compression, it is fully multi-platform, and use the OS support to load the dynamic libraries, thus ensuring full compatibility.
The main goal of PyInstaller is to be compatible with 3rd-party packages out-of-the-box. This means that, with PyInstaller, all the required tricks to make external packages work are already integrated within PyInstaller itself so that there is no user intervention required. You'll never be required to look for tricks in wikis and apply custom modification to your files or your setup scripts. As an example, libraries like PyQt, Django or matplotlib are fully supported, without having to handle plugins or external data files manually. Check our compatibility list of SupportedPackages.
i hope this helps, good luck and tell if you need anymore help

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/

How to make PyInstaller work on wxPython using 2 stage creation with XRC?

Everyone suggests switch from py2exe to PyInstaller for making a standalone executable from Python scripts. Our first trial is to make a wxPython application which makes usage of lots of 2 stage creation with XRC. It seems the building process of PyInstaller doesn't include those modules specified in .xrc files and I am wondering if we can utilize hidden imports feature or other alternatives. Any ideas?
You might find this helpful: http://www.blog.pythonlibrary.org/2010/08/10/a-pyinstaller-tutorial-build-a-binary-series/
PyInstaller's documentation also explains how to include and exclude stuff:
http://www.pyinstaller.org/export/latest/tags/1.4/doc/Manual.html?format=raw#create-a-spec-file-for-your-project
My guess is you need to explicitly include wx.xrc

Categories