内容简介:Nuitka直接将python编译成C++代码 ,再编译C++代码产生可执行文件,完全不存在反向解析的问题,非常安全,而且由于可执行文件由C++编译而来,运行速度也会获得提升。PyInstaller可以用来打包python应用程序,打包完的程序就可以在没有安装Python解释器的机器上运行了。PyInstaller支持Python 2.7和Python 3.3+。可以在Windows、Mac OS X和Linux上使用,但是并不是跨平台的,而是说你要是希望打包成.exe文件,需要在Windows系统上运行P
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) 复制代码
网上查资料是因为系统版本不符导致,具体参考: github.tiankonguse.com/blog/2017/0…
- 使用 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 复制代码
参考资料:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- 使用模块化工具打包自己开发的JS库(webpack/rollup)对比总结
- 【前端打包部署】谈一谈我在SPA项目打包=>部署的处理
- Maven多模块项目打包前的一些注意事项(打包失败)
- tar打包如何不打包某一个文件夹(排除某些文件夹)
- iOS新手用swift写一个macos打包工具 一键打包到指定位置
- 常用消息队列对比
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Hacking Growth
Sean Ellis、Morgan Brown / Crown Business / 2017-4-25 / USD 29.00
The definitive playbook by the pioneers of Growth Hacking, one of the hottest business methodologies in Silicon Valley and beyond. It seems hard to believe today, but there was a time when Airbnb w......一起来看看 《Hacking Growth》 这本书的介绍吧!