Zum Inhalt springen
Python Virtual Environments richtig nutzen
Warum virtuelle Umgebungen wichtig sind und wie man sie effektiv einsetzt.
26. Dezember 2025 durch
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. Dezember 2025
Stichwörter
Archiv
Willkommen im NerdThings Blog
Der erste Eintrag im neuen Blog über Shell, Python, AI und andere Nerd-Themen.