如何使用cx_freeze在python中创建.EXE文件 [英] How to create .EXE file in python using cx_freeze
问题描述
我有一个使用python 3.2开发的应用程序,该应用程序具有内置模块(例如Tkinter,matplotlib,openpyxl),用户定义的模块&类(例如:draw_graph,generate_report),图标文件,日志文件,.csv,.docx等。我正在通过脚本(例如:testapplication.py)运行此应用程序
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)
我的安装文件为
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]
)
现在,我想创建此应用程序的exe文件。有人可以建议我这样做吗?
Now I want to create a exe file of this application. can anyone please suggest me a way to do this?
推荐答案
这就是您需要做的。首先,将 script = r C:\Python32\testapplication.py
更改为 script = r testapplication.py
So this is what you need to do. For starters, change script=r"C:\Python32\testapplication.py"
to script=r"testapplication.py"
然后,将需要转换的所有文件放入 C / python32
,包括安装文件。然后,您需要执行的操作是打开命令行,然后键入以下命令:(假设您的cx_freeze文件名为setup.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
然后在该目录中应该有一个包含exe文件的构建文件夹。
And then you should have a build folder in that directory containing the exe file.
这篇关于如何使用cx_freeze在python中创建.EXE文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!