当需要包含非 python 文件时使用 PyInstaller 创建单个 exe?
Using PyInstaller to create single exe when there are non python files that need to be included?
有没有一种方法可以使用 PyInstaller 创建一个包含文本文件和 .ui 文件等内容的可执行文件?我该怎么做?
您可以使用 spec file:
向 pyinstaller 构建的 exe 添加项目
For example, to add a single README file to the top level of a one-folder app, you could modify the spec file as follows:
a = Analysis(...
datas=[ ('src/README.txt', '.') ],
...
)
You have made the datas= argument a one-item list. The item is a tuple in which the first string says the existing file is src/README.txt. That file will be looked up (relative to the location of the spec file) and copied into the top level of the bundled app.
The strings may use either / or \ as the path separator character. You can specify input files using “glob” abbreviations. For example to include all the .mp3 files from a certain folder:
a = Analysis(...
datas= [ ('/mygame/sfx/*.mp3', 'sfx' ) ],
...
)
有没有一种方法可以使用 PyInstaller 创建一个包含文本文件和 .ui 文件等内容的可执行文件?我该怎么做?
您可以使用 spec file:
向 pyinstaller 构建的 exe 添加项目For example, to add a single README file to the top level of a one-folder app, you could modify the spec file as follows:
a = Analysis(...
datas=[ ('src/README.txt', '.') ],
...
)
You have made the datas= argument a one-item list. The item is a tuple in which the first string says the existing file is src/README.txt. That file will be looked up (relative to the location of the spec file) and copied into the top level of the bundled app.
The strings may use either / or \ as the path separator character. You can specify input files using “glob” abbreviations. For example to include all the .mp3 files from a certain folder:
a = Analysis(...
datas= [ ('/mygame/sfx/*.mp3', 'sfx' ) ],
...
)