What is Python on Zerops?
Zerops provides a fully managed Python runtime environment with automatic scaling, built-in dependency management, and zero-config deployment. Build and deploy Python web applications, APIs, and services with enterprise-grade performance.
Python is a programming language that lets you work quickly and integrate systems more effectively. Learn more about Python →
Key Features
Multiple Python Versions Support for Python 3.8 through 3.12 with easy version switching
Automatic Scaling Horizontal and vertical auto-scaling based on actual resource usage
PIP Integration Built-in pip support for seamless dependency management
Virtual Environments Automatic virtual environment management for isolated dependencies
Supported Versions
Zerops supports multiple Python versions:
Python 3.12 (Latest)
Python 3.11
Python 3.10
Python 3.9
Python 3.8
You can change the major version at any time through the zerops.yaml configuration.
Quick Example
Deploy a Python application in minutes:
project :
name : my-python-app
services :
- hostname : app
type : python@3.12
minContainers : 1
maxContainers : 3
buildFromGit : https://github.com/zeropsio/recipe-python-hello-world@main
enableSubdomainAccess : true
Runtime Environment
The Python runtime environment includes:
Alpine Linux (default) or Ubuntu
Selected Python version
pip for dependency management
Git and wget utilities
Zerops CLI tools
Virtual environment support
Common Use Cases
Deploy high-performance FastAPI apps with automatic dependency installation and uvicorn server. zerops :
- setup : api
build :
base : python@3.12
buildCommands :
- pip install -r requirements.txt
deployFiles :
- app
- requirements.txt
run :
start : uvicorn app.main:app --host 0.0.0.0 --port 8000
Run Django applications with database migrations and static file collection. zerops :
- setup : web
build :
base : python@3.11
buildCommands :
- pip install -r requirements.txt
- python manage.py collectstatic --noinput
deployFiles : .
run :
initCommands :
- python manage.py migrate
start : gunicorn myproject.wsgi:application --bind 0.0.0.0:8000
Build RESTful APIs with Flask and custom dependencies. zerops :
- setup : api
build :
base : python@3.12
buildCommands :
- pip install -r requirements.txt
deployFiles :
- app
- requirements.txt
run :
start : flask run --host=0.0.0.0 --port=5000
Machine Learning Services
Deploy ML models with custom system dependencies. zerops :
- setup : ml-api
build :
base : python@3.11
os : ubuntu
prepareCommands :
- sudo apt-get update
- sudo apt-get install -y python3-opencv
buildCommands :
- pip install -r requirements.txt
deployFiles : .
run :
start : uvicorn app.main:app --host 0.0.0.0 --port 8000
Build Process
Standard Build
zerops :
- setup : app
build :
base : python@3.12
buildCommands :
- pip install -r requirements.txt
deployFiles :
- app
- requirements.txt
cache : ~/.cache/pip
With System Dependencies
zerops :
- setup : app
build :
base : python@3.12
os : ubuntu
prepareCommands :
- sudo apt-get update
- sudo apt-get install -y build-essential
- sudo apt-get install -y libpq-dev
buildCommands :
- pip install -r requirements.txt
deployFiles :
- app
- requirements.txt
Runtime Configuration
Custom Start Command
Specify how to start your application:
run :
start : python -m uvicorn app.main:app --host 0.0.0.0 --port 8000
With Init Commands
Run migrations or initialization tasks:
run :
initCommands :
- python manage.py migrate
- python manage.py createcachetable
start : gunicorn app.wsgi:application --bind 0.0.0.0:8000
Multiple Workers
Configure Gunicorn with multiple workers:
run :
start : gunicorn app.wsgi:application --workers 4 --bind 0.0.0.0:8000
Environment Variables
Set runtime configuration:
run :
envVariables :
DJANGO_SETTINGS_MODULE : myproject.settings.production
DEBUG : false
PYTHONUNBUFFERED : 1
Custom System Packages
Install additional system packages:
run :
os : ubuntu
prepareCommands :
- sudo apt-get update
- sudo apt-get install -y imagemagick
- sudo apt-get install -y ffmpeg
- sudo apt-get install -y postgresql-client
Port Configuration
Define custom ports:
run :
ports :
- port : 8000
protocol : TCP
httpSupport : true
Health Checks
Configure health checks for your application:
run :
healthCheck :
httpGet :
port : 8000
path : /health
Common Patterns
requirements.txt
Manage dependencies:
fastapi==0.109.0
uvicorn[standard]==0.27.0
pydantic==2.5.0
sqlalchemy==2.0.25
psycopg2-binary==2.9.9
With Poetry
Use Poetry for dependency management:
build :
buildCommands :
- pip install poetry
- poetry config virtualenvs.create false
- poetry install --no-dev
deployFiles :
- app
- pyproject.toml
- poetry.lock
Async Workers
Run async tasks with Celery:
services :
# Web server
- hostname : web
type : python@3.12
# ...
# Celery worker
- hostname : worker
type : python@3.12
# ...
# Redis for Celery
- hostname : redis
type : redis@7
Next Steps
Quickstart Guide Deploy your first Python application
Example Projects Explore Python examples on GitHub