Python使用Pyinstaller将.py文件打包成exe

Pyinstaller -F -w 文件名.py
-F, --onefile:
描述:创建一个单独的可执行文件而不是一个文件夹。
示例:pyinstaller -F your_script.py

--noconsole:

描述:打包成窗口应用程序,不显示控制台窗口。
示例:pyinstaller --noconsole your_script.py
-w, --windowed:

描述:与--noconsole相同,打包成窗口应用程序。
示例:pyinstaller -w your_script.py
--hidden-import module_name:

描述:明确指定一个依赖的模块,以确保PyInstaller正确地包含它。
示例:pyinstaller --hidden-import module_name your_script.py
--additional-hooks-dir directory:

描述:指定一个目录,该目录下的钩子脚本将被执行,用于处理PyInstaller不能自动处理的模块。
示例:pyinstaller --additional-hooks-dir=path/to/hooks your_script.py
--exclude module_name:

描述:排除指定的模块,不包含在可执行文件中。
示例:pyinstaller --exclude module_name your_script.py
--clean:

描述:在打包之前清理临时文件。
示例:pyinstaller --clean your_script.py
--distpath directory:

描述:指定可执行文件的输出目录。
示例:pyinstaller --distpath=path/to/output your_script.py
--specpath directory:

描述:指定生成的spec文件的输出目录。
示例:pyinstaller --specpath=path/to/specs your_script.py
--upx-dir directory:

描述:指定 UPX 压缩工具的路径,用于压缩生成的可执行文件。
示例:pyinstaller --upx-dir=path/to/upx your_script.py

 

posted @ 2023-12-11 21:57  XiaoHuang_Student  阅读(62)  评论(0)    收藏  举报