Python Virtual Environment (venv)
Summary:
1. Create an Environment.
2. Activate an Environment.
3. Install Individual Packages.
4. Install Packages from a file.
5. Save Packages.
Definition:
This is simply a self-contained location that enables you to maintain separate & isolated
environments for your python projects.
Advantages:
1. Manage Dependencies.
2. Packages
3. Versions
Without conflicts across different projects.
Use Case,
1. To create a directory in Linux:
python3 -m venv <name>
2. Then to access it,
source <name>/env/activate
3. To exit the environment,
deactivate
Note: pip -> preferred installer program
to install pip, (in Linux)
Sudo apt install python3-pip -y
pip3 list -> To check for all the installed or available dependencies or packages
To install a package,
Pip3 install <package_name>
pip freeze > [Link]
This will move all the installed packages or dependencies in a virtual environment
into a [Link] file.
To check, use nano or cat.
If created a new environment and add the requirements in that environment using
[Link]
Use,
pip install -r [Link]