Packages and Virtual Environments

16 min read

Almost every AI project starts the same way: you install a package that someone else wrote. In this lesson you will learn what a package is and how pip gets one. You will also learn why each project needs its own virtual environment. Last, you will see where API keys belong, and where they must never go.

New words

Package
Code that other people wrote and shared for you to use.
pip
The tool that downloads packages and installs them.
Virtual environment
A separate folder with its own packages for one project.
requirements.txt
A text file that lists the packages a project needs.
Pinning
Fixing a package to one exact version, like numpy==1.26.4.
API key
A secret code for your account, like a UPI PIN.
Environment variable
A named value kept outside your code, such as a key.

What you will learn

  1. Why this matters for AI work
  2. What is a package?
  3. Installing with pip
  4. The problem: one shared shelf
  5. The venv workflow
  6. requirements.txt: sharing your setup
  7. Try it: two projects, one computer
  8. Keep out of Git, and other tools
  9. Where to keep API keys
  10. Common mistakes
  11. Explain it to a friend
  12. Key takeaways

10 quiz questions at the end.

Start this lesson

The full lesson, with interactive demos and the quiz, opens after you sign in with Google. It is free.

All lessons · Back to the roadmap