【linux环境布置】之Python代码打包工具Nuitka

1 安装测试
1.1 安装方法
在官方的安装说明中,提供了不同平台的安装方法,我们在 linux 系统下,采用最简单的 pip 安装即可

pip install -U nuitka

安装好之后查看版本,可以看到安装的是最新的 0.6.17.7 版本。

$ python -m nuitka --version
0.6.17.7
Commercial: None
Python: 3.6.9 (default, Jan 26 2021, 15:33:00) 
Executable: /usr/bin/python
OS: Linux
Arch: aarch64

如果要查看帮助文档,使用下边的指令

$ python -m nuitka --help
1.2 简单测试
新建一个 python 测试脚本 hello.py

def talk(message):
    return "Talk " + message
 
 
def main():
    print(talk("Hello World"))
 
 
if __name__ == "__main__":
    main()

使用工具创建可执行文件,会生成 hello.bin 文件,从输出日志可以看到封装的过程

$ python -m nuitka --lto=no hello.py█████████████████████████████████████████████████████████████████████████| 10/10
Nuitka-Options:INFO: Used command line options: --lto=no hello.py
Nuitka-Options:INFO: Detected static libpython to exist, consider '--static-libpython=yes' for better performance.                                  
Nuitka:INFO: Starting Python compilation with Nuitka '0.6.17.7' on Python '3.6' commercial None.
Nuitka:INFO: Completed Python level compilation and optimization.                                                                                   
Nuitka:INFO: Generating source code for C backend compiler.
Nuitka:INFO: Running data composer tool for optimal constant value handling.                                                                        
Nuitka:INFO: Running C level backend compilation via Scons.
Nuitka-Scons:INFO: Backend C compiler: gcc (gcc).
Nuitka-Scons:WARNING: You are not using ccache.                                                                                                     
Nuitka:INFO: Keeping build directory 'hello.build'.
Nuitka:INFO: Successfully created 'hello.bin'.
运行成功后,测试一下生成的 bin 文件,输出成功,表明环境没问题
$ ./hello.bin 
Talk Hello World

关于报错:
今天在编译libid3tag的时候编译不过去有如下报错,zlib-1.2.3编译成功了,但是libid3tag make的时候报有问题,发现了有个提示是:


> ```bash /usr/bin/ld: cannot find -lz collect2: error: ld returned 1
> exit status ```

有人给出了原因:

编译的时候出现上述错误错误,需要安装zlib-dev这个包,在线安装命令为:

apt-get install zlib1g-dev -y 
或
yum install zlib1g-dev -y
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值