Skip to the workspace
Pebellslearn by building
Setting Up Your Data Toolkit  ›  Lesson

pip and Virtual Environments

virtualenv / venv 12 minEach project gets its own virtual environment, packages are installed into it with pip, and the exact versions are recorded so the setup can be rebuilt.

python data analysis / pip and Virtual Environments

Explore each scene at your own pace.

01 · The rule

The rule

pip and Virtual Environments

You have a folder of bookshop sales and a plan to analyse it with pandas. Before any analysis, the tools have to be installed, and installed in a way that will not break the project you start next month. That is the job of pip and virtual environments.

The rule

One project, one environment; install inside it, record what you installed.

pip is Python's package installer. It downloads a library from the Python Package Index and puts it where Python can import it.

A virtual environment is a private folder holding its own Python and its own installed packages. Project A can keep pandas 2.1 while project B uses pandas 2.3, and neither notices the other.

python -m venv .venv            # create the environment in a folder called .venv
source .venv/bin/activate       # switch into it (Windows: .venv\Scripts\activate)
pip install pandas numpy matplotlib
pip freeze > requirements.txt   # record exact versions

Anyone who gets your project later runs pip install -r requirements.txt inside their own fresh environment and gets the same versions.

Two other tools do the same job with a different style:

  • conda manages environments and non-Python pieces (such as compiled maths libraries). Popular in scientific work.
  • uv is a newer, very fast replacement for pip plus venv, driven by commands like uv venv and uv pip install.

The idea is identical in all three: an isolated environment per project, plus a written list of what is in it.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.