python -m venv .venvLine-by-line explanation
- Python runs its built-in
venvmodule. .venvis the folder to create.- That folder receives an isolated interpreter and package location.
Activate it in Windows PowerShell:
.venv\Scripts\Activate.ps1Line-by-line explanation
- The path points to the environment’s PowerShell activation script.
- Running it changes the current terminal session.
- The prompt normally gains
(.venv).
Activate it on macOS or Linux:
source .venv/bin/activateLine-by-line explanation
sourceruns changes in the current shell.- The path selects the environment’s activation script.
- The prompt normally gains
(.venv).
Tiny Practice
Create an environment folder named .venv.
Starter template
python -m venv CHANGE_MELine-by-line explanation
- The venv command is complete.
- Only the destination folder is missing.
Hint
- Use the common name .venv.
- Do not quote it.
- Run inside the project folder.
Show Solution
python -m venv .venvLine-by-line explanation
- Python loads venv.
- The module creates an isolated environment.
- Its files are placed in .venv.