34

I'm looking for a tutorial on PyInstaller that will explain things like

  • how to create .pkg files
  • how to include/exclude modules
  • how to include data files inside the install directory.

I cannot make much sense out of the standard PyInstaller documentation.

Brandon
  • 3,684
  • 1
  • 18
  • 25

3 Answers3

23

Both guides in the accepted answer seem outdated. PyInstaller now provides an executable script that allows you to do

pyinstaller your_script.py

wherever your_script.py is located - instead of the old mode of copying your your_script.py to wherever you copied the source code of PyInstaller.

Here's a brief, more recent guide that walks you through a simple Hello World example:

http://www.pythoncentral.io/pyinstaller-package-python-applications-windows-mac-linux/

101
  • 8,514
  • 6
  • 43
  • 69
  • 3
    The newest version of pyinstaller (2.1) is pretty neat. Check out the official [documentation](http://pythonhosted.org/PyInstaller/). It's very easy to understand and covers all the uses. – user2963623 May 14 '14 at 13:42
15

Have you looked here: simplified tutorial

Or here: a bit longer tutorial

EDIT: Adding data files is implied in the second tutorial. If you use the second example just before the "Wrapping Up" section, along with the official documentation: Analysis, it looks like you'd specify your data-file dependencies as part of the "datas" subobject when calling the Analysis() function.

EDIT2: From official documentation: "Generally, you will not need to create your own PKGs, as the EXE will do it for you. This is one way to include read-only data in a single-file deployment, however. A single-file deployment including TK support will use this technique."

Example (should be roughly like this):

a = Analysis(...)
pyz = PYZ(a.pure)
pkg = PKG(a.pure, name="PackageName")
exe = EXE(pyz, pkg,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          ...)
chisaipete
  • 884
  • 9
  • 20
  • I see your 2nd link talks about including additional modules. What about the other items I mention, or did I miss those somewhere? Thanks. – Brandon Aug 03 '11 at 12:08
  • Well, it's implied in the second tutorial, if you use this along with the official documentation--edited answer with the details that were in this edit (for continuity). – chisaipete Aug 03 '11 at 15:51
  • Both guides in the accepted answer seem outdated, and Pyinstaller now provides different API. – Arman Dec 11 '15 at 22:15
2

To Create one executable of your python script or project
create your script or project. To install pyinstaller on Windows type

pip install pyinstaller
Now open command prompt and type the command
pyinstaller --onefile myscripy.py
You will find a dist folder created. Browse dist folder and you will get .exe file of python script.
Rohit Salunke
  • 1,073
  • 1
  • 10
  • 14