python生成exe cx_如何使用cx_freeze在python中创建.EXE文件

博主有一个用Python 3.2开发的应用,包含内置模块、自定义模块等多种文件,想将其生成exe文件。解决方案是修改脚本路径,将所有需转换的文件放入C/python32,在命令行输入相关命令,最终在该目录的build文件夹中可得到exe文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

I have one application developed in python 3.2, which has inbuilt modules(ex: Tkinter, matplotlib, openpyxl), user defined modules & classes(ex: draw_graph, generate_report), icon files, log file, .csv, .docx etc. I am running this application from script(ex: testapplication.py)

I have setup file as

import sys

from cx_Freeze import setup, Executable

exe = Executable(

script=r"C:\Python32\testapplication.py",

base="Win32GUI",

)

setup(

name = "TESTApp",

version = "0.1",

description = "An example",

executables = [exe]

)

Now I want to create a exe file of this application. can anyone please suggest me a way to do this?

解决方案

So this is what you need to do. For starters, change script=r"C:\Python32\testapplication.py" to script=r"testapplication.py"

Then, put ALL the files to need to convert into C/python32 including the setup file. Then what you wan to do is get your command line up, and type the following commands: (assuming that you're cx_freeze file is named setup.py):

cd

cd python32

python setup.py build

And then you should have a build folder in that directory containing the exe file.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值