I'm trying to build an application written in python, which can run on Windows without the need to install python or associated libraries(standalone), and I want to do that on my mac. I tried Pyinstaller, but it seems to generate files executable only in a platform that is building the application(in this case, osx).
Is there easy way out like Pyinstaller or do I have to do that in a very complex way? Since I'm not the expert, the latter option might be impossible for me to do. Would it be more wise just to try to build the app on windows than mac using pyinstaller?
For pyinstaller, they have clearly mentioned that packaging Windows binaries while running under OS X is NOT supported, and recommended to use Wine for this.
1. 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.
2. Can I package Windows binaries while running under OS X?
No, this is not supported. Please try Wine for this.
3. Can I package OS X binaries while running under Linux?
This is currently not possible at all. Sorry! If
you want to help out, you are very welcome.
Related
I need to package my Python application, its dependencies, and Python itself into a single MSI installer for distribution to users. The end result should desirably be:
Python is installed in the standard location
the package and its dependencies are installed in a separate directory (possibly site-packages)
the installation directory should contain the Python uncompressed and a standalone executable is not required
Kind of a dup of this question about how to make a python into an executable.
It boils down to:
py2exe on windows, Freeze on Linux, and
py2app on Mac.
I use PyInstaller (the svn version) to create a stand-alone version of my program that includes Python and all the dependencies. It takes a little fiddling to get it to work right and include everything (as does py2exe and other similar programs, see this question), but then it works very well.
You then need to create an installer. NSIS Works great for that and is free, but it creates .exe files not .msi. If .msi is not necessary, I highly recommend it. Otherwise check out the answers to this question for other options.
My company uses the free InnoSetup tool. It is a moderately complex program that has tons of flexibility for building installers for windows. I believe that it creates .exe and not .msi files, however. InnoSetup is not python specific but we have created an installer for one of our products that installs python along with dependencies to locations specified by the user at install time.
I've had much better results with dependencies and custom folder structures using pyinstaller, and it lets you find and specify hidden imports and hooks for larger dependencies like numpy and scipy. Also a PITA, though.
py2exe will make windows executables with python bundled in.
py2exe is the best way to do this. It's a bit of a PITA to use, but the end result works very well.
Ok, I have used py2exe before and it works perfectly except for one thing... It only works on executable windows machines. I then learned about Jython which turn a python script into a .Jar file. Which as you know is executable from any machine that has Java ("To your latest running version") installed. Which is great because both unix, windows, and ios (Most of the time) Run java. That means its executable from all of the following machines. As long as they run Java. No need for "py2mac + py2exe + freeze" just to run on all operating systems. Just Jython
For more information on how it works and how you can use it click here.
http://www.jython.org/
I'm making a program in python, but once I'm finished with the program, will the users have to download the python environment in order to use my program, or will it work without the python environment once compiled? Also, will it automatically be cross-platform or will I have to download a conversion program to make it work for Linux, Mac OS and Windows? I'm new to the language so this is confusing me.
Many Linux systems come with Python installed already. However, there are some tools to help if it is not:
pyinstaller for Windows, Linux, and Mac OS X (does not work for Python 3)
bbfreeze for Windows and Linux
py2exe for Windows
Freeze for Linux
py2app for Mac OS X
Have a look at py2exe for windows, linux and mac is likely to have it preinstalled.
They would need a python interpreter to use your program unless you turn your python script into a windows executable. One way of doing that is by using Py2exe
It depends on what 3rd party libraries you include in your program.
For example I never managed to make a windows executable with the PyQt lib,
by using py2exe. But this was 2-3 years ago and things might have changed.
Also don't hardcode paths in your program and make use of functions like os.path.join
Don't make assumptions about config files and stuff. Do check on runtime the platform
your program is running on and act accordingly.
In general, your biggest problem will be the Windows platform.
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.
I hope my title was clear. I'm using wxpython for making a GUI and I want it to be able to be opened, extracted, and have it work on all operating systems. I was able to include twill by finding a folder called twill inside the twill archive, which worked fine. However, I'm unable to figure out how to correctly package wxpython.
EDIT: I'm not using either. py2exe is only for windows, and bbfreeze doesn't seem to work on mac (so it's not cross platform)
Unfortunately, there's just no one stop solution so that a single installable executable will work across all operating systems. The right solution is really to provide a different installer or executable for each OS; For windows, use py2exe, for mac, py2app is a good choice, and for linux you should just provide a tarball with a reasonable setup.py (that you will need for the first two, anyway).
You should go with the recommendation of TokenMacGuy. But I preferrably would use a tool which is able to freeze the application for all OS instead of using different ones.
cx_freeze is a good choice regarding these terms.
This is another fine alternative:
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.
Have you tried http://cx-freeze.sourceforge.net/ ?
I'm wondering how I can create a 32-bit binary with my 64bit cx_freeze. I've looked at the homepage and I can't find a setting to tell it what architecture to build for.
I'm running 32bit(otherwise PyQt won't work) Python 2.6, so the dependencies should already be 32bit, on 64bit Kubuntu 10.10.
If you were using Windows or a Mac, then you could use py2exe or py2app, respectively. I think that freeze may be a more general solution that may work for you.
Maybe this link will help you: http://linux.die.net/man/8/linux32
Otherwise you can create a x32 virtual machine by using QEmu or VirtualBox...
I have a pyqt project for which I used to distribute frozen apps before just releasing it open source, for win/linux/osx.
I used the following:
Pyinstaller for linux
Py2app for osx
Py2exe for windows
http://www.pyinstaller.org/