Modern Python development environment with latest tools, linting, and popular frameworks
This development container provides a complete Python development environment with:
- ✅ Python 3.12
- ✅ FastAPI (pre-installed)
- ✅ Django, Flask support (optional)
- ✅ Linting and formatting (Black, isort, flake8, pylint)
- ✅ Testing with pytest
- ✅ Poetry package manager
- ✅ Type checking with mypy
-
Open in VS Code
code . -
Reopen in Container
- Press
F1→Dev Containers: Reopen in Container
- Press
-
Create your first project
FastAPI:
# main.py already configured uvicorn main:app --reload --host 0.0.0.0 --port 8000Flask:
pip install flask flask run --host 0.0.0.0 --port 5000
Django:
pip install django django-admin startproject myproject cd myproject python manage.py runserver 0.0.0.0:8000
- 🐍 Python 3.12 - Latest stable Python
- ⚫ Black - Code formatter
- 🔀 isort - Import sorter
- 📏 Flake8 - Linter
- 🔍 Pylint - Static analyzer
- 🔤 MyPy - Type checker
- ✅ pytest - Testing framework
- 📊 pytest-cov - Coverage plugin
- ⚡ pytest-asyncio - Async testing
- 📦 pip - Default package manager
- 🎭 poetry - Modern dependency manager
- ⚡ FastAPI - Modern async API framework (pre-installed)
- 🌐 Django - Full-featured web framework (optional)
- 🧪 Flask - Micro web framework (optional)
- 💻 IPython - Enhanced REPL
- 🐛 ipdb - Debugger
ms-python.python- Python language supportms-python.vscode-pylance- Fast language serverms-python.black-formatter- Black formatterms-python.isort- Import organizerms-python.flake8- Linternjpwerner.autodocstring- Docstring generatorvisualstudioexptteam.vscodeintellicode- AI-assisted IntelliSense
The Dockerfile is organized in stages:
- base - Python 3.12 base image
- dev-tools - Linting, formatting, testing tools
- frameworks - Web frameworks (customize here!)
- tools - Additional utilities, poetry
- development - Final dev environment
- production - Minimal production runtime
Edit .devcontainer/Dockerfile at the frameworks stage:
FROM dev-tools AS frameworks
# Django
RUN pip install django djangorestframework celery
# Flask
RUN pip install flask flask-restful flask-sqlalchemy
# Data Science
RUN pip install numpy pandas scikit-learn matplotlib seaborn jupyterpython -m venv venv
source venv/bin/activate# Initialize new project
poetry init
# Add dependencies
poetry add fastapi uvicorn
# Install dependencies
poetry install
# Run in poetry environment
poetry run python main.py# Using pip
pip install requests pandas numpy
# Using poetry
poetry add requests pandas numpy
# Install from requirements.txt
pip install -r requirements.txt# FastAPI (with auto-reload)
uvicorn main:app --reload --host 0.0.0.0 --port 8000
# Flask
flask run --host 0.0.0.0 --port 5000
# Django
python manage.py runserver 0.0.0.0:8000# Run tests
pytest
# Run with coverage
pytest --cov=.
# Run specific test file
pytest tests/test_example.py
# Run with verbose output
pytest -v# Format code with Black
black .
# Sort imports
isort .
# Lint with flake8
flake8 .
# Analyze with pylint
pylint your_module
# Type check with mypy
mypy .Press F5 and select:
- Python: Current File - Debug current file
- Python: FastAPI - Debug FastAPI application
- Python: Flask - Debug Flask application
- Python: Django - Debug Django application
your-project/
├── .devcontainer/
│ ├── devcontainer.json
│ └── Dockerfile
├── .vscode/
│ ├── settings.json
│ └── launch.json
├── src/
│ └── your_module/
├── tests/
├── requirements.txt
├── pyproject.toml # For poetry
└── README.md
| Command | Description |
|---|---|
python main.py |
Run Python script |
pip list |
List installed packages |
pip freeze > requirements.txt |
Export dependencies |
python -m pytest |
Run tests |
black . |
Format code |
flake8 . |
Lint code |
mypy . |
Type check |
- 8000 - FastAPI/Django default
- 5000 - Flask default
- Python Documentation
- FastAPI Documentation
- Django Documentation
- Flask Documentation
- Poetry Documentation
- pytest Documentation
Feel free to customize this container for your specific needs!
Happy Coding! 🎉