Published on

How to create Python virtual environment

Authors
  • avatar
    Name
    Saad Bash

Creating a virtual environment

  1. From project directory run the below command to create virualenv:
python3 -m venv env
  1. Activate the virtualenv using:
source env/bin/activate
  1. Confirm if the virtual environment is active:
which python
  1. To leave virtual environment:
deactivate

Installing a Package:

Example:

python3 -m pip install requests

For more info: Installing packages using pip and virtual environments