pyinstall 使用
官方文档:
https://pyinstaller.readthedocs.io/en/stable/spec-files.html
(暂时先放着,有空了准备好好翻一翻官方文档)
一般先直接使用命令打包一次,再进一步编辑生成的spec文件,
常用参数说明:
–icon=图标路径
-F 打包成一个exe文件
-w 使用窗口,无控制台
-c 使用控制台,无窗口
-D 创建一个目录,里面包含exe以及其他一些依赖性文件
pyinstaller -h 来查看参数
将文件一起打包进去,会用的比较多。
Adding Files to the Bundle
To add files to the bundle, you create a list that describes the files and supply it to the Analysis
call. When you bundle to a single folder (see Bundling to One Folder), the added data files are copied into the folder with the executable. When you bundle to a single executable (see Bundling to One File), copies of added files are compressed into the executable, and expanded to the _MEI*xxxxxx*
temporary folder before execution. This means that any changes a one-file executable makes to an added file will be lost when the application ends.
In either case, to find the data files at run-time, see Run-time Information.
Adding Data Files
You can add data files to the bundle by using the --add-data
command option, or by adding them as a list to the spec file.
When using the spec file, provide a list that describes the files as the value of the datas=
argument to Analysis
. The list of data files is a list of tuples. Each tuple has two values, both of which must be strings:
- The first string specifies the file or files as they are in this system now.
- The second specifies the name of the folder to contain the files at run-time.