← Courses

Python for AI — Beginner Foundations

Data Science

Getting Started · Lesson 17 of 76

Virtual environments

Different projects often need different package versions. A virtual environment is a private box of packages for one project, so they don't clash with another project's.

Create and activate one inside your project folder:

python -m venv .venv
# macOS / Linux
source .venv/bin/activate
# Windows (PowerShell)
.venv\Scripts\Activate.ps1

Once it's active, pip install puts packages only in that project. When you're done, type deactivate. The golden rule: one virtual environment per project.

You’re reading for free. Sign in to keep your progress and earn a certificate when you finish.Sign in to keep my progress →