0Pricing
Django Academy · Lesson

Virtual Environments with venv

Isolate dependencies so projects never collide.

Virtual Environments with venv is a free Django Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Django Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Why Isolate Dependencies

Every project needs its own libraries. A virtual environment keeps each project's packages separate, so one app never breaks another. 🧳

The Problem with Global Installs

Installing packages globally mixes versions across projects. One upgrade can suddenly break an older app that relied on the old version.

Meet venv

Python ships with venv, a built-in tool that creates an isolated folder holding its own Python and packages. No extra install needed.

Create an Environment

Run one command to build a fresh environment. The venv folder appears in your project, ready to hold your packages.

python -m venv venv

Activate on macOS and Linux

You must activate the environment before using it. On macOS or Linux, source the activate script in your terminal.

source venv/bin/activate

Activate on Windows

On Windows the path differs slightly. The same activate step turns the environment on for your current shell session.

venv\Scripts\activate

Spot an Active Environment

Once active, your prompt shows the environment name in parentheses. That little (venv) tag confirms you are isolated. ✅

Install Into the Environment

With the environment active, anything you install with pip lands inside venv only, never touching your system Python.

pip install requests

Deactivate When Done

Finished working? Run one word to leave the environment. deactivate returns your shell to the normal system Python.

deactivate

Keep venv Out of Git

The venv folder is large and machine-specific. Add it to .gitignore so it never gets committed to your repository.

echo venv/ >> .gitignore

One Environment per Project

Give every project its own environment. This isolation means each app pins exactly the versions it was built and tested against.

Quick Check

Let's confirm how activation works.

Recap

You learned to create, activate, and deactivate a venv, keeping each project's packages isolated and out of Git. Clean foundations! 🎉

Frequently asked questions

Is the “Virtual Environments with venv” lesson free?

Yes — the full text of “Virtual Environments with venv” is free to read here on the web, and the Django Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Django Academy course, upgrade to CoddyKit PRO.

What will I learn in “Virtual Environments with venv”?

Isolate dependencies so projects never collide. You practise Django Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Django Academy?

No prior experience is required. Django Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Virtual Environments with venv” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Django Academy lesson?

Yes. Every Django Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Virtual Environments with venv
  2. pip install django and Pinning Versions
  3. django-admin startproject Explained
  4. Run the Dev Server with runserver
← Back to Django Academy