▶ Sign up free for the video, slides & prompts
The lesson below is open to all. Enter your email once to unlock every video, slide deck, prompt and code example on this device.
Checking…
pip and packages
Install libraries others have built.
🎬 Video version coming soon — read it now
Beyond the standard library, there are more than half a million free packages on PyPI (the Python Package Index), written by people all over the world. pip is the tool that installs them.
Installing a package
In a terminal:
In Colab, put ! in front to run it as a shell command:
Many popular packages, including pandas, numpy and matplotlib, are already installed in Colab.
Using it
Note that the install name and import name are usually the same, but not always: you install beautifulsoup4 and import bs4.
Useful pip commands
requirements.txt is how you share a project: anyone can recreate your setup with one command.
Packages worth knowing
- requests: call web APIs
- pandas, numpy, matplotlib: data analysis and charts
- scikit-learn: machine learning
- openai, anthropic, google-genai: AI model SDKs
- fastapi: build web APIs (in the Production Python course)
- python-dotenv: load secrets from a .env file
Install safely
Anyone can publish to PyPI, and attackers upload fake packages with names like reqeusts or pandaz, hoping you make a typo. Before installing something unfamiliar:
- Check the spelling carefully
- Look it up on pypi.org: downloads, recent releases and a linked source repository are good signs
- Be especially careful with package names suggested by AI tools. They sometimes invent packages that don't exist, and attackers register those names
In one line
pip installs packages from PyPI; save them in requirements.txt, and check names carefully before installing anything unfamiliar.
Share with a friend