Nuitka直接將python編譯成C++代碼 ,再編譯C++代碼產生可執行文件,徹底不存在反向解析的問題,很是安全,並且因爲可執行文件由C++編譯而來,運行速度也會得到提高。html
PyInstaller能夠用來打包python應用程序,打包完的程序就能夠在沒有安裝Python解釋器的機器上運行了。PyInstaller支持Python 2.7和Python 3.3+。能夠在Windows、Mac OS X和Linux上使用,可是並非跨平臺的,而是說你要是但願打包成.exe文件,須要在Windows系統上運行PyInstaller進行打包工做;打包成mac app,須要在Mac OS上使用。python
文件名:hello.py
git
代碼內容:github
#!/bin/env python
print 'hello world!'
複製代碼
# 本地安裝
mkdir nuitka_source && cd nuitka_source
git clone https://github.com/Nuitka/Nuitka.git ./
python setup.py install
複製代碼
# 編譯單個文件
nuitka ./hello.py
# 編譯某個目錄的全部文件
nuitka ./hello.py --include-plugin-directory=./ --remove-output --output-dir=./output -o ./output/hello
--include-plugin-directory: 編譯依賴的目錄
--remove-output: 移除編譯輸出的中間態文件
--output-dir: 指定輸出信息的文件目錄
-o: 指定輸出的文件名(需包含所在目錄)
複製代碼
# pip 方式安裝
pip install pyinstaller
# pip 方式更新
pip install --upgrade pyinstaller
# 本地安裝
mkdir pyinstaller_source && cd pyinstaller_source
git clone https://github.com/pyinstaller/pyinstaller.git ./
python setup.py install
複製代碼
pyinstaller -F ./hello.py
複製代碼
Floating point exception (core dumped)
複製代碼
網上查資料是由於系統版本不符致使,具體參考: github.tiankonguse.com/blog/2017/0…安全
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 (do not warn), --follow-imports (recurse to all), --nofollow-import-to=colored_cli (ignore it), --follow-import-to=colored_cli (recurse to it) to change.
The gcc compiler gcc (version 3.4.5) doesn't have the sufficient version (>= 4.4). 複製代碼
解決方案:bash
export PATH=/opt/compiler/gcc-4.8.2/bin:$PATH
複製代碼