py2exe如何将外部文件夹嵌入已发布的bundle ex

2024-04-20 15:23:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个文件夹myFolder(其中包含一些文件和子文件夹,这些文件和子文件夹被存放在我的模块.py)在py2exe安装程序旁边,我想将这个文件夹作为一个包嵌入到最终发布的exe文件中。在

设置文件中的我的代码:

from distutils.core import setup
import py2exe

setup(windows=[{'script':"myModule.py",'uac_info': "requireAdministrator","icon_resources": [(1, "icon.ico")]}], options={'py2exe':{'bundle_files': 1}},zipfile = None)

有可能吗?在

Python 2.7.6


Tags: 模块文件代码frompycoreimport文件夹
1条回答
网友
1楼 · 发布于 2024-04-20 15:23:03

是的上面的答案就是你想要的。在

1.you must add foldernames to your setup file.
2.py2exe will compress and save that folders in one exe file(out come is only one exe)
3. when runnig exe.that folders will recreated automaticaly (py2exe will decompress it and put it back to computr)

在上面的答案有一个链接检查它。。 在这个链接中有一个函数可以帮助你添加大量的文件和文件夹 不需要一个接一个地写(你只需要提供foldername和target)

示例:如果您有一个文件,则必须按如下方式写入路径名“天文学.png“在你的电脑里 如果你想在“targetpath”中安装时放回去

^{pr2}$

这是您必须在py2exe的安装文件中写入的元组

我想你的问题是“很多文件和文件夹” 你不需要一个接一个地写文件名,因为link中有一个函数..读那个。。在

相关问题 更多 >