记录使用cx_Freeze打包Python成exe可执行程序

安装Python

Python环境:Python 3.6.5

安装cx_Freeze

pip install cx_freeze

创建setup.py

在需要打包的py文件同级目录创建setup.py文件

import sys
import os
from cx_Freeze import setup, Executable

os.environ['TCL_LIBRARY'] = r'D:\Python\Python36\tcl\tcl8.6'
os.environ['TK_LIBRARY'] = r'D:\Python\Python36\tcl\tk8.6'

base = None
if sys.platform == 'win32':
    base = 'Win32GUI'

executables = [
    Executable('index.py', targetName='index.exe', base=base)
]

include_files = [
    r'D:\Python\Python36\DLLs\tcl86t.dll',
    r'D:\Python\Python36\DLLs\tk86t.dll'
]

buildOptions = dict(
    packages=[], excludes=[],
    include_files=include_files,
)

setup(
    name='测试1.0',
    version='1.0',
    description='测试',
    options=dict(build_exe=buildOptions),
    executables=executables
)

执行打包

切换到setup.py目录

执行 python setup.py build

打包成功,打包后的文件如下:

运行index.exe,效果如下:

 

转载于:https://www.cnblogs.com/doocool/p/9119578.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值