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文件


猜你喜欢

转载自blog.csdn.net/u011270542/article/details/80429986