How to bundle a Python application including dependencies?

PythonTkinterPackaging

Python Problem Overview


I need to package my Python application, its dependencies and Python into a single MSI installer. 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

Python Solutions


Solution 1 - Python

Solution 2 - Python

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.

Solution 3 - Python

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.

Solution 4 - Python

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.

Solution 5 - Python

py2exe will make windows executables with python bundled in.

Solution 6 - Python

py2exe is the best way to do this. It's a bit of a PITA to use, but the end result works very well.

Solution 7 - Python

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/

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionFlorian BöschView Question on Stackoverflow
Solution 1 - PythonpjzView Answer on Stackoverflow
Solution 2 - PythondF.View Answer on Stackoverflow
Solution 3 - PythonMikeView Answer on Stackoverflow
Solution 4 - PythonwwwslingerView Answer on Stackoverflow
Solution 5 - PythonWilliam KellerView Answer on Stackoverflow
Solution 6 - PythonSerafina BrociousView Answer on Stackoverflow
Solution 7 - PythonPython and Android for lifeView Answer on Stackoverflow