python开发windows桌面应用程序-py转exe文件

实现python生成.exe文件

1、使用py2exe(如果python的版本是3.4以后的版本,不支持,会产生报错信息)

2、如果是python3.6版本的,可以使用cx_freeze实现exe文件生产

参考:

1、https://stackoverflow.com/questions/41578808/python-indexerror-tuple-index-out-of-range-when-using-py2exe

2、http://www.pythontab.com/html/2014/pythongui_0123/684.html

3、

https://my.csdn.net/my/mycsdn?c=4846f5daece29550788ecafda6447424&c=6cd7cf11b01c9eccd61af799a980f1e5&c=755b2c147146c70d41e1cd40207e8883


实际操作过程:

1、在app.py同一目录下建立文件,setup.py 内容根据需要增删改,

#setup.py
import sys, os
from cx_Freeze import setup, Executable

__version__ = "1.1.0"

#include_files = ['logging.ini', 'config.ini', 'running.png']
include_files = []
excludes = ["tkinter"]
#packages = ["os", "idna", "requests","json","base64","pyodbc"]
packages = ["os", "idna", "requests","json","base64"]

setup(
    name = "appname",
    description='App Description',
    version=__version__,
    options = {"build_exe": {
    'packages': packages,
    'include_files': include_files,
    'excludes': excludes,
    'include_msvcr': True,
}},
executables = [Executable("boxLayout.py",base="Win32GUI")]
)

2、执行命令 

python setup.py bdist_msi


之后生成两个文件夹,build 和dist


在build\exe.win32-3.6找到生成的exe文件


  • 1
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值