PyInstaller 来建立Linux下的Python独立执行文件


以下内容假定已安装好Python 2.4/2.5

一、下载并编译pyinstaller(只需做一次,以后可直接做第二步)

1.下载pyinstaller,现在的版本是1.3
(1)wget http://pyinstaller.hpcf.upr.edu/source/1.3/pyinstaller_1.3.tar.gz

2.解包进入源码目录
(1)tar zxv pyinstaller_1.3.tar.gz
(2)cd pyinstaller-1.3/source/linux

3.编译源代码
(1)python Make.py  生成python的 .pyc文件

如无错误,则出现如下提示(只有一行):
Now run "make" to build the targets: ../../support/loader/run ../../support/loader/run_d

(2)make 连接生成linux的 .o 文件

4.生成编译配置文件
(1)python Configure.py  生成config.dat配置文件


二、编译独立运行的python可执行文件

1.生成spec文件
python pyinstaller-1.3/Makespec.py --onefile --upx linuxlaptop.py

参数说明:
--onefile 生成单文件
--upx          生成压缩的文件(可减小执行文件体积,需先安装upx软件包)


2.生成最终的可执行文件
python pyinstaller-1.3/Build.py linuxlaptop.spec

相关内容