Foundations — Virtual environments and pip - conda
This page builds up every word and symbol the parent 1.4.10 note uses, starting from things a curious 12-year-old already knows: files, folders, and typing commands. Nothing below assumes you have seen a terminal before.
1. A file, a folder, and a path
Before any Python, we need the most basic object: a path.

What to look for in the figure: every rounded box is a folder, and the thin lines are the parent→child links. The deepest boxes (bottom row) hold actual package files. Notice the green branch (system packages) and the orange branch (venv packages) never touch — that separation is isolation. When the parent note says a venv is a "self-contained directory tree", it means exactly one of these branches, kept apart from the others.
Why do we need this word first? Because isolation — the whole point of the topic — is nothing more than "keep packages in separate branches of this tree so they never touch."
2. import — asking Python for a package
When you write:
import numpyyou are handing Python a name (numpy) and saying "go find the folder called this and load it." But Python does not search the whole disk — that would be slow. It only looks in a short, ordered list of folders.
3. sys.path — the ordered list of search folders
Here is the single most important symbol in the whole topic.
import sys
print(sys.path)
# ['', '/usr/lib/python3.10', '/usr/lib/python3.10/site-packages', ...]
What to look for in the figure: read it like a checklist Python runs top to bottom. The first row is the '' current-folder entry. The blue arrow on the left shows the search direction. Python finds numpy in the highlighted green row, loads it, and the red "stop!" arrow shows it never looks at the rows below. This "first match wins" rule is the mechanism behind everything:
4. site-packages/ — where installed packages live
So the two symbols connect:
site-packages/= where packages physically sit.sys.path= the list that includes that folder so Python knows to look there.
A virtual environment gives you a brand-new empty site-packages/ and puts it near the top of sys.path. That is the entire trick — a fresh drawer, checked first.
5. .dist-info/ and metadata — the version label
When a package is installed, alongside its code goes a small folder ending in .dist-info/.
The == you keep seeing is not maths equality — it is a filter:
6. venv — the built-in tool that makes an environment
Before we edit any lists, we need the tool that creates the isolated folder.
7. $PATH and $VIRTUAL_ENV — the shell's version of sys.path
There are two search lists in play, and mixing them up causes most confusion. sys.path is for Python imports. $PATH is for which program the word python even runs.

What to look for in the figure: the top block is $PATH before activation — python is found in a system folder. The bottom block is after activation — the orange venv/bin folder has been slipped in at the front, so now python resolves there first. It is the same "first match wins" rule as sys.path, just for programs instead of imports. When you activate an environment, the activate script runs:
export PATH="/path/to/venv/bin:$PATH"
export VIRTUAL_ENV="/path/to/venv"export= "make this variable visible to programs I run."- Putting
venv/binin front means the wordpythonnow findsvenv/bin/pythonfirst. $VIRTUAL_ENVis a signpost variable recording which env is active (used to show the(venv)prompt).
8. Activate / deactivate — flipping the switch
9. pip vs conda — the two installers, in one line each
You now hold every symbol needed to read the parent note end to end.
Prerequisite map
The diagram below is written in Mermaid, a plain-text way to draw diagrams. Read it as a set of boxes joined by arrows: each box is a concept, and an arrow A --> B means "A must be understood before B." Follow the arrows top to bottom — everything funnels into the final "Virtual environment isolation" box.
Related building blocks: reading/writing files like requirements.txt, packages such as NumPy you will install, and why MKL-optimized builds matter.
Equipment checklist
Test yourself — cover the right side and answer aloud.
What is a path?
/ on Linux/Mac, \ on Windows).What does import numpy make Python do?
sys.path top-to-bottom for a folder named numpy and load the first match.What is sys.path?
What does the empty string '' mean at the front of sys.path?
python from, checked before everything else.What is site-packages/?
What command creates a virtual environment, and where does the tool come from?
python -m venv myenv; venv is a module built into Python 3.3+, no install needed.What does the rule "first match wins" imply if a folder is at the top of the list?
What does numpy==1.24.0 mean, and is it maths equality?
When do two version specifiers create a conflict?
>=1.20 and <1.20), so no single version satisfies both.What is $PATH and how does it differ from sys.path?
$PATH is the shell's list for finding programs like python; sys.path is Python's list for finding imports. Both use first-match-wins.What does the activate script actually change?
venv/bin to $PATH and sets $VIRTUAL_ENV, for the current terminal only.