# Python Virtual Environments for Makers

Learn why Python projects use virtual environments and how to prove which interpreter and packages are active.

## Outcome
Run a project with the intended Python interpreter and dependency set.

## Safe first step
python -V and which python show which interpreter your shell will use.

## Ladder steps
### 1. Find the interpreter
The python command can point to different executables.

Check: which python and python -V agree with the project.

### 2. Create an environment
A virtual environment isolates packages from the system Python.

Check: The venv directory contains its own bin/python.

### 3. Activate deliberately
Activation changes PATH for the current shell.

Check: which python points inside the venv.

### 4. Freeze only when useful
requirements files record dependencies for another environment.

Check: pip freeze should match the project, not global clutter.

## Examples
### Check active Python
```sh
python -V && which python
```
Expected signal: Version and executable path

### Create a local virtual environment
```sh
python -m venv .venv
```
Expected signal: A .venv folder with bin/python

### Activate and list packages
```sh
. .venv/bin/activate && python -m pip list
```
Expected signal: Packages installed in that environment

## Common traps
- Installing with one pip and running another python.
- Committing a whole virtual environment.
- Using sudo pip for a project dependency.

## Practice task
Create a tiny venv, install one package, and prove which python and pip are active.

## Next steps
- Learn Git ignores.
- Learn deployment paths.
- Learn package lock errors.

## Related
- [Package lock troubleshooting](https://linuxoneliners.com/problems/package-lock-held/)
