Log inSign up

Python guides

Python 3 and pip, virtual environments, Flask, FastAPI, Django, Celery and bots. 12 guides in this topic.

Install Python 3, pip and venv

Set up Python 3 with pip and virtual environments on Ubuntu, Debian, Rocky or Alma, plus pipx, uv and newer interpreters next to the system one.

Run legacy Python 2 code

Keep an old Python 2.7 program running while you port it: container images, pyenv builds, the last distro package, and how to fence the risk in.

Manage Python projects with Poetry

Use Poetry 2 to declare dependencies, lock exact versions and install the same environment on a server, then run the app under systemd.

Miniconda and Anaconda on a server

Install Miniforge, Miniconda or full Anaconda on a Linux server, build reproducible conda environments, and understand the channel terms first.

Deploy Flask with Gunicorn and Nginx

Serve a Flask app in production: Gunicorn under systemd on localhost, Nginx in front with HTTPS, firewall rules, graceful reloads and uWSGI as an option.

Deploy FastAPI with Uvicorn workers

Run a FastAPI service in production with several Uvicorn worker processes under systemd, Nginx in front with HTTPS and WebSocket support.

Deploy Django with Gunicorn and Nginx

Run a Django project in production: PostgreSQL, a virtual environment, Gunicorn under systemd, Nginx for static files and HTTPS from Certbot.

Background tasks with Celery and Redis

Move slow jobs out of your web requests with Celery workers, a password protected Redis broker, scheduled tasks with beat and systemd units.

Host a Python Discord bot

Keep a discord.py bot online around the clock: its own system user, a virtual environment, the token in an env file and a systemd service that restarts it.

Containerise a Python web app

Package a Python web app in a slim multi-stage Docker image with a non-root user, run it with Compose next to PostgreSQL and publish it safely.

JupyterLab on a server

Run JupyterLab on a VPS as a systemd service with a password, then reach it through an SSH tunnel or through Nginx with HTTPS and websockets.

Host a Python Telegram bot

Run a Telegram bot built with python-telegram-bot or aiogram as a systemd service, using long polling or a webhook behind Nginx with HTTPS.