Comprehensive tutorial on Pyinstaller?

Question:

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.

Asked By: Brandon

||

Answers:

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,
          ...)
Answered By: chisaipete

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/

Answered By: user2042696

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.

Answered By: Rohit Salunke