Virtual Environments (venv/conda)
Part of the AI Engineer Roadmap
In short
Your old project needs one version of numpy, your new LLM project needs another. Install both globally and one of them breaks. A virtual environment gives every project its own private set of packages.
Isolated Python environments per project so package versions (numpy, torch, transformers) don't conflict across your different AI projects.

Think of it like this
Separate tiffin boxes
If you pour rajma, kadhi and kheer into one big dabba, lunch is ruined. Pack them in separate tiffins and each stays as it should. A virtual environment is a separate tiffin for each project, so packages from one never leak into another.
Watch it happen
Two projects, two environments
1/4Your projects folder holds two separate projects.
The big ideas
What you need to know
An environment is just a folder
It holds its own Python and its own installed packages. Delete the folder and the environment is gone, nothing else is touched.
venv comes with Python
python -m venv .venv creates one. No extra install needed, and it's enough for most projects.
conda also manages non-Python stuff
conda can install Python itself plus compiled libraries. Many data science setups use it for that reason.
Never commit the environment
Add .venv to .gitignore. Share a requirements.txt instead, so others can rebuild it.
How it works
Starting any new AI project
- 1
Make the folder
Create the project folder and cd into it.
- 2
Create the env
Run python -m venv .venv once.
- 3
Activate it
Your terminal prompt shows (.venv) when it's active.
- 4
Install and freeze
pip install what you need, then save the list to requirements.txt.
See it in code
Walk through the code
1# create and activate (macOS / Linux)2python3 -m venv .venv3source .venv/bin/activate4 5# on Windows PowerShell instead:6# .venv\Scripts\Activate.ps17 8which python # .../my-project/.venv/bin/python9pip install numpy pandas10 11deactivate # back to the system Python1/4Create the .venv folder, then activate it for this terminal session.
After activating, which python points inside your project. That's how you know installs will stay in this project only.
Save yourself the pain
Common mistakes
Oops
Running pip install in a new terminal and forgetting to activate the env first.
Do this instead
Check for (.venv) in your prompt, or run which python, before every install.
Oops
Pushing the whole .venv folder to GitHub.
Do this instead
Ignore .venv in .gitignore and commit requirements.txt. It's a few lines instead of hundreds of megabytes.
Your mission
Two projects, two numpys
Quick check
You activated .venv in one terminal, then opened a second terminal and ran pip install torch. Where did torch go?
Go deeper
- 1Create and activate a venv or conda environment from scratch.
- 2Learn to export and recreate an environment with requirements.txt or environment.yml.
- 3Practice switching between environments for two different projects with conflicting dependencies.
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.