A modern web-based Python playground built with Vue 3, Vite, Monaco Editor, and Pyodide. Write and execute Python code directly in your browser!
- 🎯 Real-time Python execution - Run Python code instantly in the browser
- 📝 Monaco Editor - Full-featured code editor with syntax highlighting, autocomplete, and error detection
- 🎨 Modern UI - Beautiful, responsive interface built with Vue 3
- 📚 Code Examples - Pre-built examples to get you started quickly
- 📁 File Upload - Upload and load Python files (.py, .txt, .pyw) directly into the editor
- 💾 Download Code - Save your work as a Python file
- 📦 Package Manager - Install and manage Python packages on-demand
- 🔥 Zero Setup - No Python installation required, everything runs in the browser
- 📱 Responsive Design - Works great on desktop and mobile devices
- Frontend Framework: Vue 3 with TypeScript
- Build Tool: Vite
- Code Editor: @guolao/vue-monaco-editor
- Python Runtime: Pyodide
- State Management: Pinia
- Styling: Modern CSS with responsive design
- Node.js (version 16 or higher)
- npm or yarn
- Clone the repository:
git clone https://github.com/hypnguyen1209/python-playground.git
cd python-playground
- Install dependencies:
npm install
- Start the development server:
npm run dev
- Open your browser and navigate to
http://localhost:5173
npm run dev
- Start the development servernpm run build
- Build for productionnpm run preview
- Preview the production buildnpm run lint
- Run ESLintnpm run format
- Format code with Prettier
- Write Code: Use the Monaco Editor on the left to write your Python code
- Upload Files: Click "Upload File" to load existing Python files into the editor
- Run Code: Click the "Run Code" button to execute your Python code
- View Output: See the results in the output panel on the right
- Load Examples: Use the dropdown to load pre-built code examples
- Install Packages: Use the package manager panel to install additional Python libraries
- Download Code: Save your work using the "Download" button
- Clear Output: Use the "Clear Output" button to reset the output panel
The playground comes with Python's standard library. Additional packages can be installed on-demand using Pyodide's package system. Common packages include:
- numpy - Numerical computing
- pandas - Data analysis and manipulation
- matplotlib - Plotting and visualization
- scipy - Scientific computing
- pycryptodome - Crypto library
- requests - HTTP library
- beautifulsoup4 - Web scraping
- micropip - Package installer for Pyodide
The playground includes several built-in examples:
- Hello World - Basic Python syntax
- Data Structures - Lists, dictionaries, and sets
- Loops and Functions - Control flow and function definitions
- Data Analysis - Statistics and data processing
- File Processing - Text analysis (great for testing uploads!)
- Object-Oriented Programming - Classes and objects
🌐 Live Demo: https://hypnguyen1209.github.io/python-playground/
The application features:
- Write or upload Python code
- Click "Run Code" to execute
- View results in real-time
- Install packages as needed
- Download your work when done
- Frontend: Vue 3 with Composition API and TypeScript
- Editor: Monaco Editor (same as VS Code) with Python language support
- Python Runtime: Pyodide (CPython compiled to WebAssembly)
- State Management: Pinia for reactive state
- Build System: Vite with modern ES modules
- Styling: CSS Grid/Flexbox with responsive design
Contributions are welcome! Please feel free to submit a Pull Request.
Pyodide Loading Slowly
- Pyodide downloads ~6MB on first load
- Subsequent loads are cached by the browser
- Check browser console for loading progress
Package Installation Fails
- Not all PyPI packages are available in Pyodide
- Check Pyodide package list
- Some packages may require additional setup
Code Execution Errors
- Check Python syntax in the editor
- Some advanced Python features may not be supported
- File system operations are limited in browser environment
- Chrome/Edge: Full support ✅
- Firefox: Full support ✅
- Safari: Full support ✅
- Mobile browsers: Basic support
⚠️
npm run build
The build output will be in the dist/
directory, ready for deployment to any static hosting service.
This project includes automatic deployment to GitHub Pages via GitHub Actions:
- Setup: The repository includes a
.github/workflows/deploy.yml
workflow file - Automatic: Deploys automatically on every push to the
main
branch - Manual: Can also be triggered manually from the Actions tab
- Live URL: Once deployed, access at
https://hypnguyen1209.github.io/python-playground/
- Go to your repository Settings
- Navigate to "Pages" in the sidebar
- Under "Source", select "GitHub Actions"
- The workflow will automatically deploy on the next push
- Vercel:
vercel --prod
- Netlify: Drag & drop the
dist/
folder - Firebase Hosting:
firebase deploy
No environment variables required - everything runs client-side!
This project is licensed under the MIT License.
- Pyodide - Python in the browser
- Monaco Editor - Code editor from VS Code
- Vue.js - Progressive JavaScript framework
- Vite - Next generation frontend tooling
🔥 Powered by hypnguyen1209