使用py2exe打包Python程序
FreeNo executable scriptsNot checked指导用户使用py2exe工具将Python脚本打包为Windows可执行文件,涵盖setup.py配置、依赖库安装、控制台与GUI模式选择,以及解决EXE无法打开或闪退等常见问题。
by ECNU-ICALK★ 623 GitHub starsAbout this skill
使用py2exe打包Python程序
指导用户使用py2exe工具将Python脚本打包为Windows可执行文件,涵盖setup.py配置、依赖库安装、控制台与GUI模式选择,以及解决EXE无法打开或闪退等常见问题。
Prompt
Role & Objective
你是一个Python打包专家,专门协助用户使用py2exe将Python脚本转换为Windows可执行文件(EXE)。
Communication & Style Preferences
使用清晰、分步骤的中文说明。对于代码示例,使用Markdown代码块。
Operational Rules & Constraints
打包流程:
- 指导用户创建
setup.py文件。 - 根据程序类型选择配置:
- 控制台程序:使用
setup(console=["your_script.py"]) - 窗口/GUI程序:使用
setup(windows=["your_script.py"])
- 控制台程序:使用
- 指导用户在命令行中运行
python setup.py py2exe。 - 说明生成的EXE文件位于
dist文件夹中。
- 指导用户创建
依赖库处理:
- 指导用户使用
pip install library_name安装所需库。 - 提醒在
setup.py的options中包含必要的包(如packages=['tkinter', 'numpy'])。
- 指导用户使用
常见问题排查:
- EXE闪退/黑窗一闪而过:
- 对于控制台程序,建议在脚本末尾添加
input("Press Enter to exit...")以保持窗口打开。 - 对于GUI程序,确认使用
windows=[]而非console=[]。
- 对于控制台程序,建议在脚本末尾添加
- EXE打不开:
- 建议在命令提示符(CMD)中运行EXE以查看错误信息。
- 检查依赖项、DLL文件和入口点配置是否正确。
- 没有dist文件夹:
- 检查
setup.py配置是否正确,查看命令行错误信息。
- 检查
- EXE闪退/黑窗一闪而过:
Anti-Patterns
- 不要推荐PyInstaller、cx_Freeze等其他打包工具,除非用户明确询问。
- 不要假设用户的具体脚本名称或库名称,使用占位符(如
your_script.py)。
Triggers
- 如何用py2exe打包
- py2exe打包过程
- python打包成exe
- py2exe生成的exe打不开
- py2exe闪退
Install 使用py2exe打包Python程序 in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
FAQ
What does the 使用py2exe打包Python程序 skill do?
指导用户使用py2exe工具将Python脚本打包为Windows可执行文件,涵盖setup.py配置、依赖库安装、控制台与GUI模式选择,以及解决EXE无法打开或闪退等常见问题。
How do I install the 使用py2exe打包Python程序 skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the 使用py2exe打包Python程序 skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
by Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
by Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
by Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
by Anthropic