python打包工具比较_Python 打包工具对比,Nuitka vs Pyinstaller

Nuitka直接将 python 编译成C++代码 ,再编译C++代码产生可执行文件,完全不存在反向解析的问题,非常安全,而且由于可执行文件由C++编译而来,运行速度也会获得提升。

PyInstaller

PyInstaller可以用来打包python应用程序,打包完的程序就可以在没有安装Python解释器的机器上运行了。PyInstaller支持Python 2.7和Python 3.3+。可以在Windows、Mac OS X和 Linux 上使用,但是并不是跨平台的,而是说你要是希望打包成.exe文件,需要在Windows系统上运行PyInstaller进行打包工作;打包成mac app,需要在Mac OS上使用。

软件安装 & 使用

测试文件

文件名:hello.py

代码内容:

#!/bin/env python

print 'hello world!'

复制代码

Nuitka

安装

# 本地安装

mkdir nuitka_source && cd nuitka_source

git clone https://github.com/Nuitka/Nuitka.git ./

python setup.py install

复制代码

使用

nuitka ./hello.py

复制代码

PyInstaller

安装

# 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

复制代码

遇到的问题

开发机上安装完 pyinstaller 工具之后,执行产出的编译文件,会报错,报错信息如下:

Floating point exception (core dumped)

复制代码

使用 nuitka 工具时,因为开发机默认的gcc版本过低,导致报错,报错信息如下:

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).

复制代码

解决方案:

export PATH=/opt/compiler/gcc-4.8.2/bin:$PATH

复制代码

参考资料:

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值