首页 > 编程知识 正文

linuxpython脚本使用教程,python运行py文件的几种方法

时间:2023-05-06 06:07:44 阅读:245210 作者:727

以下内容假定已安装好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

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。