When comparing cx_Freeze vs Pyinstaller, the Slant community recommends cx_Freeze for most people. In the question“What are the best tools for creating packaged executables for Python?” cx_Freeze is ranked 2nd while Pyinstaller is ranked 3rd. The most important reason people chose cx_Freeze is:
If you have a Python Script, you can use cx_Freeze to turn it into an executable on the platform you use it for. It will run on any platform where Python itself runs on. Note, however, that it can't cross-compile.
Ranked in these QuestionsQuestion Ranking
Pros
Pro It's cross platform
If you have a Python Script, you can use cx_Freeze to turn it into an executable on the platform you use it for. It will run on any platform where Python itself runs on.
Note, however, that it can't cross-compile.
Pro Egg support
Support for searching zip files (.egg files) for modules.
Pro Easy to use
PyInstaller is one of the best tools for easily freezing Python Scripts and Modules into self-contained executables. It can be used via CLI with a single command and without many configurations. This tool pulls all the necessary files and libraries needed into a file to have your program run on any PC as an executable app.
Pro Easy install
Simply pip install pyinstaller
and it is ready to go.
Pro Compatible with most 3rd-party packages out-of-the-box
Most packages will work without any configuration. The community maintains a list of tested packages here. The list is incomplete so any user can contribute to it by editing the table or writing to the mailing list.
Pro Compatible with Cython modules
Pyinstaller can resolve, use, and package Cython modules into the executable.
Pro Can obfuscate Python byte code
Python bytecode can be obfuscated by specifying an encryption key with a CLI command. This should prevent most forms of tampering with the executable, such as reverse-engineering it to extract the underlying Python code. While the bytecode is encrypted using AES256, it should not be confused for security because the key can be extracted from the executable.
Pro Can add binariess to the executable
The --add-binary
flag allows you to bundle external executables along with your script. You can, for example, bundle chromium or selenium.
Cons
Con Needs you to use a setup script
Won't detect that a file needs to be copied if it is not dynamically loaded by your program, you have to tell cx_Freeze about it in a setup script.
Con Not a cross-compiler
While you can use cx_Freeze on any platform where python itself works on, you can't cross-compile (compile an app for another platform).
Con Source code can be obtained
Since cx_Freeze does not provide solutions to reverse engineering or decompiling. Python bytecode can be obtained and the logic of your app can be exposed.
Con Single file mode not supported
Can't compile all your script modules, dependencies and archives into a single executable stand alone file.
Con OS Specific
Any executable created can only run on the OS, bit size, and python version it was created on. If you want to create a package that runs on another machine you will need to know these exact parameters in order for it to function.
Con Not highly configurable
There is an option to dictate that the package should be completely run from one file, but other than a few other modification commands pyinstaller is not very configurable.
Con Fails to produce .exe
Produces nothing in the \dist directory, no .exe file, nothing except a \setup directory. A waste of disk space. I have a simple single python .py file, marginally above "hello", no user input, a simple parse of known binary file to a known text file. Copious unintelligible output to no effect.