11/30/2021

Pyinstaller

PyInstaller bundles a Python application and all its dependencies into a single package. If you’re using a virtual environment, remember to activate it before installing PyInstaller. After installation, the pyinstaller binary is located in your virtual environment’s bin/ directory, or where your Python executable is located. If that directory isn’t in your PATH, include the whole path when you run pyinstaller. PyInstaller bundles a Python application and all its dependencies into a single package. The user can run the packaged app without installing a Python interpreter or any modules. Help keeping PyInstaller alive: Maintaining PyInstaller is a huge amount of work. PyInstaller development can only continue if users and companies provide sustainable.

PyInstaller lets you freeze your python application into astand-alone executable. This installer supports Linux, macOS, Windows, and more; and is alsocompatible with 3rd-party Python modules, such as PySide6.

Pyinstaller include file

For more details, see the official documentation.

Status of Qt 6 Support¶

As of March 2021, Qt 6 is not supported yet. PyInstaller is unable to properlydeploy Qt; the Qt plugins are not copied. With that, using –onefile is notpossible.

It is possible to use PyInstaller for the non –onefile case though bymanually copying the Qt plugins, QML imports and translations intothe dist directory after running PyInstaller.

On Windows, this can be achieved by running the windeployqt toolfrom the Qt SDK on the Qt libraries present in the dist directory, forexample:

Preparation¶

Install the PyInstaller via pip with the following command:

If you’re using a virtual environment, remember to activate it before installing PyInstaller.

After installation, the pyinstaller binary is located in your virtual environment’s bin/directory, or where your Python executable is located. If that directory isn’t in your PATH,include the whole path when you run pyinstaller.

Warning

Pyinstaller vs py2exe

If you already have a PySide6 or Shiboken6 version installed in yoursystem path, PyInstaller uses them instead of your virtual environment version.

Freeze an application¶

PyInstaller has many options that you can use. To list them all, run pyinstaller -h.

There are two main features:

Py2exe

  • the option to package the whole project (including shared libraries) into one executable file(–onefile)

  • the option to place it in a directory containing the libraries

Additionally, on Windows when the command is running, you can open a console with the -c option(or –console or –nowindowed equivalent).

Otherwise, you can specify to not open such a console window on macOS and Windows with the -woption (or –windowed or –noconsole equivalent).

Create an example¶

Now, consider the following script, named hello.py:

Since it has a UI, you use the –windowed option.

Pyinstaller github

The command line to proceed looks like this:

This process creates two directories: dist/ and build/. The application executable and therequired shared libraries are placed in dist/MyApplication.

To run the application, go to dist/MyApplication and run the program:

Note

The directory inside dist/ and the executable have the same name.

Use the –onefile option if you prefer to have everything bundled into one executable, withoutthe shared libraries next to it:

This process takes a bit longer, but in the end you have one executable in the dist/ directory:

Some Caveats¶

PyInstaller Issue¶

As mentioned before, if available, PyInstaller picks a system installation of PySide6 orShiboken6 instead of your virtualenv version without notice. This is negligible if thosetwo versions are the same.

If you’re working with different versions, this can result in frustrating debugging sessionswhen you think you are testing the latest version, but PyInstaller is working with an olderversion.

Safety Instructions¶

  • When using PyInstaller with virtualenv, make sure that there is no systeminstallation of PySide6 or shiboken6.

  • Before compiling, use pip -uninstall pyside6 shiboken6 -y multiple times, untilnone of the programs are found anymore.

  • Pip is usually a good tool. But to be 100 % sure, you should directly removethe PySide6 and shiboken6 folders from site-packages.

  • Be sure to use the right version of pip. The safest way to really run the rightpip, is to use the Python that you mean: Instead of the pip command, better use:

© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.

Hi
How can I install and use pyinstaller under Kali linux

I appricate your help with an example

  • 2 Contributors
  • forum4 Replies
  • 4,575 Views
  • 3 Days Discussion Span
  • commentLatest PostLatest Postby tony75

Recommended Answers

Pyinstaller Spec File

Hi,

you should not need the win32 version, just download the archive to a specific path, for example ~/sources/, extract and create a link to /usr/bin/ so that the script is available through the system:

Jump to Post

All 4 Replies

I think I found solution!
[email protected]:~# wine ~/.wine/drive_c/Python27/python.exe /usr/share/pyinstaller/pyinstaller.py /root/Desktop/1.py

Pyinstaller

[email protected]:~# cd /root/build/pyi.win32/
[email protected]:~/build/pyi.win32# ls
output_file
[email protected]:~/build/pyi.win32# cd output_file/
[email protected]:~/build/pyi.win32/output_file# ls