Versions, Isolation, and Reading Errors

✦ Why projects need isolated dependencies

Two projects on one machine will eventually need different versions of the same library. If everything is installed globally, one of them breaks. The fix in Python is a virtual environment, a directory holding that project's own packages, created with python3 -m venv .venv and switched on with source .venv/bin/activate. In JavaScript, node_modules already sits inside the project, so isolation is the default.

Recording what a project needs. An installed package is no use if the next person cannot reproduce it.

Python writes pip3 freeze > requirements.txt and installs with pip3 install -r requirements.txt.

JavaScript records dependencies in package.json automatically, and npm install with no arguments installs everything listed there.

This is why cloning a project and running one install command usually works. Somebody recorded the requirements.

Reading an error properly. When something fails, the error is usually telling you exactly what is wrong, and the instinct to skim it is the enemy.

`

zsh: command not found: python

`

That is not a mystery. It says a program by that name is not on PATH. So you check: which python, then which python3, and discover the name is different on your machine. The routine is always the same: read the whole error, identify what specifically failed, check the name and the path, check it is installed, and only then start changing things.

SANKOFA SANDBOX
learner:~$

Try it → Run `python --version` and read the failure. Then `which python`, then `which python3`, then `python3 --version`. That four command sequence is the whole diagnostic routine. Then try `python3 -m venv .venv` and `ls -a` to see it appear.

◈ Graded Task

Set up a project properly. Create a directory called studio, move into it, initialize a Node package with defaults, install its dependencies, and create a Python virtual environment called .venv inside it.

Checked against the filesystem you leave behind, not the commands you type, so any route that gets the job done counts. 5 visible and 2 hidden checks.

SANKOFA SANDBOX
learner:~$

Mark this lesson complete

Signed in, your progress follows you to every device.

Next: Practice Test →
← Back