Ir al contenido

Python Virtual Environments richtig nutzen

Warum virtuelle Umgebungen wichtig sind und wie man sie effektiv einsetzt.
26 de diciembre de 2025 por
Python Virtual Environments richtig nutzen
IT-Guy
python venv development

Python Virtual Environments richtig nutzen

Warum virtuelle Umgebungen wichtig sind und wie man sie effektiv einsetzt.

M
Martin Schmid
2025-12-28

Das Problem

Jeder Python-Entwickler kennt das Problem: Projekt A braucht Django 4.2, Projekt B noch Django 3.2. Ohne Isolation endet das im Chaos.

Die Lösung: Virtual Environments

# Erstellen einer virtuellen Umgebung
$ python -m venv .venv

# Aktivieren
$ source .venv/bin/activate

# Pakete installieren
(.venv) $ pip install django==4.2

UV statt pip

Mein Tipp: Nutze uv statt pip. Es ist 10-100x schneller:

# Installation
$ pip install uv

# Pakete installieren
$ uv pip install -r requirements.txt

Best Practices

  1. Eine Umgebung pro Projekt - Keine globalen Installationen
  2. requirements.txt pflegen - Immer mit Versionen
  3. .venv in .gitignore - Nie ins Repository committen
  4. Aktivierung automatisieren - z.B. mit direnv

Saubere Umgebungen = sauberer Code!

Python Virtual Environments richtig nutzen
IT-Guy 26 de diciembre de 2025
Palabras clave
Archivo
Welcome to the NerdThings Blog
The first post in the new blog about Shell, Python, AI and other nerd topics.