cx_freeze打包Python程序

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)

猜你喜欢

转载自blog.csdn.net/fenglwh/article/details/50980523