python怎么打包_如何将一整个python工程打包

匿名用户

1级

2016-05-14 回答

1、下载并安装py2exe,可下载最新版本。

2、编写安装脚本,比较简单,不过多解释,如下:

Screenshot_setup.py

#!/usr/bin/env python

# -*- coding: utf-8 -*-

from distutils.core import setup

import py2exe

includes = ["encodings", "encodings.*"]

data_files = ['CameraDll.dll']

options = {"py2exe":

{ "compressed": 1,

"optimize": 2,

"bundle_files": 1,

"includes": includes

}

}

setup(

version = "1.0",

description = "Screenshot Tool",

name = "Screenshot Tool",

options = options,

zipfile=None,

data_files = data_files,

console=[{"script": "Screenshot.py", "icon_resources": [(1, "Screenshot.ico")] }]

)

各参数含义见第5小节或执行python命令行下执行help(py2exe)查看。

3、打包程序:

a、将要找包的程序、文件和打包脚本放在同一目录下,如下:

E:\tmp\pyexe_tmp>tree /F

文件夹 PATH 列表

卷序列号码为 0007F240 101F:F68D

E:.

CameraDll.dll

screenshot.ico

Screenshot.py

screenshot_setup.py

没有子文件夹

E:\tmp\pyexe_tmp>

b、执行打包脚本:

E:\tmp\pyexe_tmp>python screenshot_setup.py py2exe

python screenshot_setup.py py2exe

running py2exe

creating E:\tmp\pyexe_tmp\build

creating E:\tmp\pyexe_tmp\build\bdist.win32

creating E:\tmp\pyexe_tmp\build\bdist.win32\winexe

creating E:\tmp\pyexe_tmp\build\bdist.win32\winexe\collect-2.6

creating E:\tmp\pyexe_tmp\build\bdist.win32\winexe\bundle-2.6

creating E:\tmp\pyexe_tmp\build\bdist.win32\winexe\temp

creating E:\tmp\pyexe_tmp\dist

*** searching for required modules ***

*** parsing results ***

*** finding dlls needed ***

*** create binaries ***

*** byte compile python files ***

writing byte-compilation script 'e:\tmp\tmp1ecbcw.py'

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值