linux下使用pyinstaller打包python脚本

最近给运维写一个系统维护的python脚本,但是被告知生产环境有很多服务器没有安装python解释器,于是在网上搜索多pyinstaller解决方案,本文简单记录之。

  1. 下载pyinstaller。

最新的pyinstaller版本为2.0版本,官方网站http://www.pyinstaller.org。下载链接:http://jaist.dl.sourceforge.net/project/pyinstaller/2.0/pyinstaller-2.0.zip

  1. 安装

在linux环境下只需要解压就可以使用。

  1. 使用

pyinstaller_path/pyinstaller.py yourscript.py

命令完成后会在当前目录生成一个yourscript目录,里面有build目录,dist目录。dist目录里面还有一个yourscript目录,这个里面就是生成的可直接运行的程序和一些依赖的包了。

如果只想生成一个单一文件,就加上-F选项。

pyinstaller_path/pyinstaller.py -F yourscript.py

同样在dist目录下面会生成一个单一的可执行文件。

ref: https://blog.csdn.net/aaronjzhang/article/details/8778338

猜你喜欢

转载自blog.csdn.net/pushiqiang/article/details/80682086