Py2Exe – Advanced Python to EXE Converter for VS Code
A powerful Visual Studio Code extension that converts Python scripts into standalone Windows executables using PyInstaller with advanced configuration options, progress tracking, and build management.
✨ Features
Core Functionality
- One-click conversion directly from the editor toolbar
- Smart file detection - works with active Python files or file picker
- Build progress tracking with real-time notifications
- Automatic PyInstaller detection and installation prompts
Advanced Options
- Executable types: Single file or directory-based executables
- Application modes: Console or windowed (no console) applications
- Icon management: Default icons, custom selection, or no icon
- Hidden imports support for complex dependencies
- Data files inclusion (source:destination mapping)
- Additional PyInstaller arguments for full control
Configuration & Management
- VS Code settings integration with persistent configuration
- Custom output directories for better project organization
- Automatic cleanup of build files and temporary artifacts
- Build file management with dedicated clean command
- Custom Python path support for virtual environments
User Experience
- Input validation for executable names
- Post-build actions: Run, open in Explorer, or open terminal
- Error handling with clear feedback and solutions
- Progress indication during build process
- Terminal integration for build output visibility
🚀 Quick Start
- Install the extension from the VS Code Marketplace
- Open a Python file in the editor
- Click "Convert to EXE" in the editor toolbar or use the command palette
- Configure options in the dialog prompts
- Wait for completion and choose post-build action
⚙️ Configuration
The extension can be configured through VS Code settings (py2exe.*):
| Setting |
Type |
Default |
Description |
py2exe.defaultOutputDir |
string |
"dist" |
Default output directory for executables |
py2exe.autoClean |
boolean |
false |
Automatically clean build files after successful compilation |
py2exe.defaultIconPath |
string |
"" |
Default icon path for executables |
py2exe.advancedMode |
boolean |
false |
Enable advanced PyInstaller options |
py2exe.pythonPath |
string |
"" |
Custom Python executable path |
Advanced Mode
When py2exe.advancedMode is enabled, you'll have access to:
- Additional PyInstaller arguments (e.g.,
--upx-dir=/path/to/upx --debug=all)
- Hidden imports (comma-separated module names)
- Data files (source:destination pairs, comma-separated)
📋 Requirements
- Visual Studio Code 1.107.0 or higher
- Python 3.7 or higher
- PyInstaller (auto-detected and can be installed automatically)
🛠️ Commands
| Command |
ID |
Description |
| Convert to EXE |
py2exe.convert |
Convert current Python file to executable |
| Configure Settings |
py2exe.configure |
Open Py2Exe settings in VS Code |
| Clean Build Files |
py2exe.clean |
Remove build artifacts and temporary files |
📁 Build Process
The extension follows this build workflow:
- File Selection - Active Python file or file picker
- Configuration - Name, type, icon, and advanced options
- Validation - Check PyInstaller installation
- Build - Execute PyInstaller with progress tracking
- Completion - Post-build actions and cleanup (if enabled)
🎯 Usage Examples
Basic Conversion
- Open
my_app.py in VS Code
- Click the "Convert to EXE" button in the editor toolbar
- Enter executable name:
my_app
- Choose "Single file executable" and "Console application"
- Select "No icon"
- Wait for completion and choose "Run EXE"
Advanced Conversion with Icon
- Use command palette: "Py2Exe: Convert to EXE"
- Select your Python file
- Enter name:
advanced_app
- Choose "Directory-based executable" and "Windowed application"
- Select "Choose custom icon" and pick your
.ico file
- Enable advanced mode for hidden imports:
numpy,pandas,matplotlib
- Add data files:
assets:data,config.json:config.json
🔧 Troubleshooting
Common Issues
PyInstaller not found
- Extension will prompt to install automatically
- Or install manually:
pip install pyinstaller
Build fails with import errors
- Use advanced mode to add hidden imports
- Check that all dependencies are installed in your Python environment
EXE doesn't run on other machines
- Ensure all required data files are included
- Test on clean Windows environment
- Consider using directory-based mode for complex applications
Permission errors
- Run VS Code as administrator if needed
- Check antivirus software isn't blocking the process
Debug Tips
- Check the terminal output for detailed PyInstaller logs
- Verify Python environment with correct dependencies
- Test with simple script first to isolate issues
- Use clean command to remove corrupted build files
📝 Development
Building the Extension
npm install
npm run compile
Testing
npm run test
Packaging
vsce package
🤝 Contributing
Contributions are welcome! Please feel free to submit issues, feature requests, or pull requests.
📄 License
This extension is licensed under the MIT License.
- Python - Official Python extension for VS Code
- Python Docstring Generator - Generate docstrings automatically
- Python Test Explorer - Run and debug Python tests
📊 Changelog
v0.1.1
- Added advanced configuration options
- Improved error handling and user feedback
- Added progress indication during builds
- Implemented build file management
- Enhanced package metadata and documentation
v0.1.0
- Initial release with basic PyInstaller integration
- One-click conversion from editor toolbar
- Basic icon and console options
Made with ❤️ for the Python community