Update venv detail

This commit is contained in:
Dita Aji Pratama 2026-01-04 22:16:42 +07:00
parent db8449fe68
commit b6bc2e6661

View File

@ -14,7 +14,41 @@ When a project is no longer needed, deleting its virtual environment is straight
## How it works?
When you run `python3 -m venv your_venv_directory_name`, Python creates a directory for “A mini Python install just for this project”. When you activate it with `source .venv/bin/activate`, your shell is told "When I type `python` or `pip`, use the ones inside `.venv`", Nothing else changes. So, when you type `pip install requests`, it installs only inside `.venv`. Then, you can deactivate venv with `deactivate` command.
When you run:
```sh
python3 -m venv your_venv_directory_name
```
Python creates a directory for *“A mini Python install just for this project”*.
When you activate it with
```sh
source your_venv_directory_name/bin/activate
```
You should see
```sh
(your_venv_directory_name)
```
your shell is told *"When I type `python` or [pip](pages/requirement/pip.md), use the ones inside `your_venv_directory_name`"*, Nothing else changes.
So, when you type:
```sh
pip install requests
```
it installs only inside `your_venv_directory_name`.
Then, you can deactivate venv with this command:
```sh
deactivate
```
## Why I add `venv` on my `gitignore`?