Tool to compare

Nuitka

Nuitka compiles python directly to C++ code, and then compiles C++ code to produce an executable file. There is no problem with reverse parsing, it is very safe, and since the executable is compiled from C++, it also runs faster.

PyInstaller

PyInstaller can be used to package Python applications that run on machines that do not have a Python interpreter installed. PyInstaller supports Python 2.7 and Python 3.3+. It works on Windows, Mac OS X and Linux, but it’s not cross-platform. If you want to package it as an.exe file, you need to run PyInstaller on your Windows system. Packaged as a MAC App, it needs to work on MAC OS.

Software installation & use

The test file

File name: hello.py

Code content:

#! /bin/env python
print 'hello world! '
Copy the code

Nuitka

The installation

# Local install
mkdir nuitka_source && cd nuitka_source
git clone https://github.com/Nuitka/Nuitka.git ./
python setup.py install
Copy the code

use

# Compile a single file
nuitka ./hello.py

Compile all files in a directorynuitka ./hello.py --include-plugin-directory=./ --remove-output --output-dir=./output -o ./output/hello --include-plugin-directory: specifies the directory that the compiler depends on. --remove-output: specifies the intermediate file that the compiler outputs. --output-dir: specifies the directory in which the output information is generated.Copy the code

PyInstaller

The installation

# PIP installation
pip install pyinstaller

# PIP mode update
pip install --upgrade pyinstaller

# Local install
mkdir pyinstaller_source && cd pyinstaller_source
git clone https://github.com/pyinstaller/pyinstaller.git ./
python setup.py install
Copy the code

use

pyinstaller -F ./hello.py
Copy the code

Problems encountered

  1. After the PyInstaller tool is installed on the developer, an error message is displayed when the compiled file is executed.
Floating point exception (core dumped)
Copy the code

Because Internet information system version does not lead to, specific reference: github.tiankonguse.com/blog/2017/0…

  1. When the nuitka tool is used, an error message is displayed as follows:
Input: nuitka hello.py
Nuitka:WARNING:Not recursing to 'log_parser' (/home/work/wangming/code/videoae/script_offline/uniondata/log_parser.py), please specify --nofollow-imports (do not warn), --follow-imports (recurse to all), --nofollow-import-to=log_parser (ignore it), --follow-import-to=log_parser (recurse to it) to change.
Nuitka:WARNING:Not recursing to 'field_dict' (/home/work/wangming/code/videoae/script_offline/uniondata/field_dict.py), please specify --nofollow-imports (do not warn), --follow-imports (recurse to all), --nofollow-import-to=field_dict (ignore it), --follow-import-to=field_dict (recurse to it) to change.
Nuitka:WARNING:Not recursing to 'colored_cli' (/home/work/wangming/code/videoae/script_offline/uniondata/colored_cli.py), please specify --nofollow-imports (donot warn), --follow-imports (recurse to all), --nofollow-import-to=colored_cli (ignore it), -- follow-importto =colored_cli (recurse to it) to change. The GCC compiler GCC (version 3.4.5) doesn'tNot have the sufficient version (>= 4.4).Copy the code

Solution:

exportPATH = / opt/compiler/GCC - 4.8.2 / bin:$PATH
Copy the code

References:

  1. www.twblogs.net/a/5b879b592…
  2. Blog.csdn.net/qwemicheal/…
  3. www.helplib.com/GitHub/arti…