您的位置:首页 > 编程语言 > Python开发

cx_freeze打包Python程序

2016-03-25 15:24 603 查看
Python程序打包成exe:

两种比较好的方法:cx_freeze和pyinstaller。

cx_freeze用起来简单,Pyinstaller功能强能打包成单个文件。

先说cx_freeze.

安装完cx_freeze以后创建cx_freeze.bat,方法如下:

python cxfreeze-postinstall

或者手懒的直接自己创建:

@echo off

C:\Python34\python.exe C:\Python34\Scripts\cxfreeze %*

之后新建一个Python文件,内容如下,运行下就成了,用于UI的,不想要黑框,就用下面的win32gui的。

# -*-coding:utf-8-*-
import os
__author__ = 'Adair'
dist_path = r'C:\Users\RF-LAB\Desktop\dist'
target_file = r'OTAcore.py'
# os.system(r'C:\Python34\Scripts\cxfreeze.bat %s --target-dir %s' % (target_file, dist_path))
os.system(r'C:\Python34\Scripts\cxfreeze.bat %s --target-dir %s --base-name=win32gui' % (target_file, dist_path)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: