0% found this document useful (0 votes)
8 views2 pages

Python venv: Create & Manage Environments

The document outlines the process of using Python's virtual environment (venv) to create, activate, and manage isolated environments for projects. It includes commands for creating an environment, installing packages, saving dependencies to a requirements.txt file, and reinstalling them. The advantages of using venv include managing dependencies and avoiding conflicts across different projects.

Uploaded by

vishalanand2502
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Python venv: Create & Manage Environments

The document outlines the process of using Python's virtual environment (venv) to create, activate, and manage isolated environments for projects. It includes commands for creating an environment, installing packages, saving dependencies to a requirements.txt file, and reinstalling them. The advantages of using venv include managing dependencies and avoiding conflicts across different projects.

Uploaded by

vishalanand2502
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

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]

You might also like