liveBook · Manning

Virtual environment

As explained in Django in Action

A Python virtual environment is an isolated environment containing a separate package installation and interpreter context for a project.

A virtual environment is a self-contained Python setup, isolated from other environments. It gives a project its own package installation so one project’s dependencies do not collide with another’s. section 2.2

Create and activate one before installing Django. Once active, `python -m pip install django` installs Django into that environment rather than making it available across the whole system. section 2.2

A typical project setup is:

  • Create a project directory and run `python3.12 -m venv ./venv`. section 2.2
  • Activate it with `source venv/bin/activate`; the shell prompt shows `(venv)`. section 2.2
  • Install Django, then use `django-admin` to create the project skeleton. section 2.2
RiffMates$ source venv/bin/activate   #1
(venv) RiffMates$ python -m pip install django   #2

The commands show activation followed by a Django installation inside the active environment. section 2.2

How Django in Action covers it

How deep it goes
Defines isolation and demonstrates creating, activating, and installing Django, while deferring fuller virtual-environment technology details.
Examples
Demonstrates a RiffMates directory using `python3.12 -m venv ./venv`, activation, and Django installation.
What you can do after
Operate/configure an isolated environment before installing Django and creating a project.
How it connects
Connects virtual environments with pip, Django, django-admin, and Python package installation.

Also explained in

Compare how 7 books explain virtual environment →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Django in Action. The section links point to the parts of the book it draws on.