djenv#
1. What is djenv?#
djenv is a Python virtual environment (venv).
- It is:
Created by me
Not created by Django
Not part of Django code
Used to isolate Python + Django + packages
Command you used:
python3 -m venv djenv
2. Why djenv exists#
- Without a virtual environment:
Django installs globally
Version conflicts happen
Projects break each other
- With djenv:
Each project has its own Python world
You can delete it anytime
Safe for learning & production
One project = one venv
π Whatβs inside djenv
djenv/
βββ bin/
βββ include/
βββ lib/
βββ pyvenv.cfg
βββ .gitignore
1οΈβ£ bin/
This is the heart of the virtual environment.
- Contains:
python
pip
django-admin
activate
Key files youβll use:
djenv/bin/activate
djenv/bin/python
djenv/bin/pip
When you run:
source djenv/bin/activate
You are telling the system:
βFrom now on, use Python and pip from THIS folder.β
Thatβs why your terminal shows:
(djenv)
2οΈβ£ lib/
This is where all installed Python packages live.
After:
pip install Django
Django is installed here:
djenv/lib/python3.x/site-packages/django/
Nothing here should be edited manually.
3οΈβ£ include/
- Used for:
C headers
Native extensions
You usually never touch this.
4οΈβ£ pyvenv.cfg
This file describes the virtual environment.
Example contents:
home = /usr/bin/python3
include-system-site-packages = false
version = 3.x.x
- Meaning:
Which Python created the venv
Whether global packages are allowed
5οΈβ£ .gitignore
Prevents committing venv files to Git.
Never push djenv to GitHub.
Instead, use:
requirements.txt
π How djenv is used (daily workflow)
Activate
source djenv/bin/activate
Install packages
python -m pip install Django
Run Django
python manage.py runserver
Deactivate
deactivate
Relationship between djenv and Django
Item |
Role |
|---|---|
djenv |
Python environment |
Django |
Installed inside djenv |
mysite |
Django project |
myapp |
Django app |
Django runs using Python from djenv.
- What djenv is NOT
Not Django project
Not Django app
Not settings
Not production code
It is just an isolated runtime environment.
- Analogy (easy to remember)
π§° djenv β toolbox
π mysite β building
π§± myapp β rooms inside the building