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

我有一个文件夹myFolder(包含一些在myModule.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

最佳答案 是的以上答案是你想要的.

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和目标)

示例:如果计算机中有文件“iam.png”,则必须按如下方式编写路径名
—-如果你想在“targetpath”中安装时放回去

("c://targetpath","c.//currentpath/iam.png")

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

我认为你的问题是“很多文件和文件夹”
    你不需要一个人写一个文件名,因为link..read中有一个函数..

点赞