Quick answer: Python 3 ships with every modern Linux distro. Add the tooling with sudo apt install python3-pip python3-venv (Ubuntu/Debian) or sudo dnf install python3-pip (AlmaLinux/Rocky), and always work inside a virtual environment (python3 -m venv) instead of installing packages system-wide.

Overview

Python powers web backends (Django, Flask, FastAPI), automation and data tooling. The golden rule on servers: never pip install into the system Python — distros rely on it and now actively block it ("externally managed environment"). Virtual environments keep every project's dependencies isolated.

Before you start

  • SSH access with sudo (how to connect).
  • Check the version: python3 --version.

Step-by-step guide

  1. Install pip and venv:
    # Ubuntu/Debian
    sudo apt -y install python3-pip python3-venv
    # AlmaLinux/Rocky
    sudo dnf -y install python3-pip
  2. Create a project environment:
    mkdir -p ~/myproject && cd ~/myproject
    python3 -m venv .venv
    source .venv/bin/activate
  3. Install dependencies inside it:
    pip install --upgrade pip
    pip install -r requirements.txt   # or: pip install flask
  4. Deactivate with deactivate; re-activate with source .venv/bin/activate.
  5. For CLI tools (not project deps), use pipx: sudo apt install pipx && pipx install httpie.

Common issues

  • error: externally-managed-environment: you tried system-wide pip — create a venv instead.
  • Wrong Python in service units: point systemd/cron to the venv's absolute path: /home/user/myproject/.venv/bin/python.
  • Build failures on pip install: install build deps: sudo apt install build-essential python3-dev.

When to contact support

Python environments are application-level; contact us via ticket for server-level faults or to upsize resources for heavier workloads.

Frequently asked questions

Why does pip say "externally-managed-environment"?

Modern distros block system-wide pip installs to protect OS tooling. Create a virtual environment with "python3 -m venv .venv" and install packages inside it.

Do I need a virtual environment for every project?

Yes, that is the standard practice: each project gets its own venv so dependency versions never conflict between projects or with the system Python.

How do I run a venv app from systemd or cron?

Point the unit or crontab at the venv's absolute interpreter path, e.g. /home/user/myproject/.venv/bin/python — no activation step is needed for absolute paths.

Related articles

Ready to get started? Order a VPS at Cloud2Y →

Was this answer helpful? 0 Users Found This Useful (0 Votes)