如何将具有多个python脚本和图像的pygame程序转换为exe? [英] How do I convert my pygame program which has multiple python scripts and images to a exe?
问题描述
我有3个python脚本以及文件夹和tmx文件中的许多图像,我希望将其作为单个.exe进行处理.我找不到如何将多个python脚本和文件夹转换为单个exe的方法.我只能为单个python脚本找到cxfreeze和类似的东西.请帮忙.
I have 3 python scripts and many images in folders and tmx files which I want to make it as a single .exe . I wasnt able to find how to convert multiple python scripts and folders to single exe. I was only able to find cxfreeze and similar things for a single python script. Please help.
谢谢.
推荐答案
在cxfreeze中创建setup.py文件.您必须在cxfreeze可执行文件中将多个pyhton文件作为列表传递.引用此线程-
Create a setup.py file in cxfreeze. You have to pass multiple pyhton files as list in cxfreeze executables. Refere this thread -
用于两个或多个python文件的Python cx_Freeze(模块)
对于单独的文件(例如图像),您必须明确包含这些文件.以下是为我在其中一个项目上工作的示例-
For separate files like images, you have to include those files explicitly. Below is an example which worked for me on one of the project -
from cx_Freeze import setup, Executable
build_exe_options = {'packages': ['os', 'tkinter', 'matplotlib.backends.backend_svg', 'subprocess'],
'namespace_packages': ['mpl_toolkits'],
'include_files':['input3.json', 'SF.xlsx', 'SF logo.ico', 'Operative Temperature.pkl',
'Rect_icon.png', 'Soltissim logo.png', 'SF full logo.jpg', 'IES logo.jpg']}
base = None
if sys.platform == 'win32':
base = 'Win32GUI'
setup ( name = 'Soltissim',
version = '2',
description = 'SF GUI',
options = {'build_exe': build_exe_options},
executables = [Executable('Soltissim.py', base=base, icon='SF logo.ico'),
Executable('SF_English.py', base=base, icon='SF logo.ico'),
Executable('SF_French.py', base=base, icon='SF logo.ico')])
另外,如果您想从安装程序创建可用于inno之类的程序的构建,请在终端中使用以下命令-python setup.py build
Furhter, if you want to create a build from setup which can be then used in program like inno, use following command in terminal - python setup.py build
如果您想直接从安装程序创建简单的Windows安装程序,请使用-python setup.py bdist_msi
If you want to create a simple windows installer directly from setup, use - python setup.py bdist_msi
这篇关于如何将具有多个python脚本和图像的pygame程序转换为exe?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!