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

Using Python Virtual Environments the Right Way

Why virtual environments matter and how to use them effectively.

M
Martin Schmid
2025-12-28

The problem

Every Python developer knows the problem: project A needs Django 4.2, project B still needs Django 3.2. Without isolation this ends in chaos.

The solution: virtual environments

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

# Aktivieren
$ source .venv/bin/activate

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

UV instead of pip

My tip: use uv instead of pip. It is 10-100x faster:

# Installation
$ pip install uv

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

Best practices

  1. One environment per project - no global installations
  2. Maintain requirements.txt - always with versions
  3. .venv in .gitignore - never commit it to the repository
  4. Automate activation - e.g. with direnv

Clean environments = clean code!

Python Virtual Environments richtig nutzen
IT-Guy 26 de diciembre de 2025
Etiquetas
Archivar
Bienvenido al blog NerdThings
La primera entrada del nuevo blog sobre shell, Python, IA y otros temas de nerd.