Virtual Environments & Package Management
Part of the Data Science Roadmap
In short
Project A needs one version of pandas, project B needs another, and installing both on one laptop breaks something. Virtual environments give each project its own private set of packages.
Isolating a project's dependencies (via venv, conda, or similar) so different projects' library versions don't conflict — a small habit that prevents a lot of 'it works on my machine' pain.

Think of it like this
Separate tiffin boxes
You don't pour dal, rice and kheer into one box, or everything tastes strange. Each goes in its own compartment. A virtual environment is a separate compartment of Python packages for each project, so nothing leaks into the others.
Watch it happen
Two projects, two environments
1/4One laptop, one system Python. Installing everything there causes version clashes.
The big ideas
What you need to know
One environment per project
Create a .venv inside each project folder and activate it before installing anything.
Pin your versions
pip freeze > requirements.txt records exactly what you installed so results can be reproduced.
Many tools, same idea
venv with pip, conda, and newer tools like uv all create isolated environments.
Don't commit the .venv
Add .venv to .gitignore. Share requirements.txt instead; others rebuild it in a minute.
See it in code
Walk through the code
1# Create and activate a project environment2python3 -m venv .venv3source .venv/bin/activate # Windows: .venv\Scripts\activate4 5pip install pandas scikit-learn6pip freeze > requirements.txt # record exact versions7 8# On another laptop, or for a teammate9python3 -m venv .venv && source .venv/bin/activate10pip install -r requirements.txt1/3Create a .venv folder and switch your terminal into it.
Your prompt usually shows (.venv) once it's active. Anything you pip install now stays inside this project.
Save yourself the pain
Common mistakes
Oops
Running pip install for every project into your system Python.
Do this instead
Activate the project's environment first. Check with 'which python' that it points inside .venv.
Oops
Sharing a project without a requirements file.
Do this instead
Always include requirements.txt (or your tool's lock file) so others get the same versions.
Your mission
Set up a clean project
Quick check
Why commit requirements.txt but not the .venv folder?
Go deeper
- 1Create a virtual environment for a new project and install packages inside it.
- 2Learn to export a requirements.txt (or environment.yml) so others can reproduce your setup.
- 3Practice switching between two environments with different library versions.
More topics at this stop
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.