Complete beginner-friendly explanation with workflow
A virtual environment in Python is an isolated workspace that contains its own Python interpreter and libraries, separate from the system-wide Python installation.
It ensures that each project has its own dependencies without interfering with other projects.
Think of a virtual environment like separate mobile apps on your phone. Each app has its own storage and settings â updating one app does not affect others.
Navigate to your project folder:
cd my_project
Create virtual environment:
python -m venv venvâ write any name
This will create a venv folder inside your project.
.\venv\Scripts\activate
source venv/bin/activate
If activated correctly, you will see (venv) in terminal.
deactivate
pip install numpy pandas flask
These packages will be installed only for this project.