Installing Python Packages
Learn how to add new tools to Python using pip
What You'll Learn
- What are Python packages
- How to install packages with pip
- Installing packages you'll use for data analysis
What are Packages?
Think of packages like apps on your phone. Python comes with basic tools, but packages add extra features.
Examples:
pandas- Work with data tablesmatplotlib- Create charts and graphsrequests- Get data from websites
Installing Packages with pip
pip is like an app store for Python. It comes automatically when you install Python.
Basic Command
pip install pandasThat's it! Just type this in your terminal/command prompt.
Step by Step
Windows:
- Press Windows key
- Type "cmd" and press Enter
- Type:
pip install pandas - Press Enter
- Wait for it to finish
Mac:
- Press Cmd + Space
- Type "terminal" and press Enter
- Type:
pip install pandas - Press Enter
- Wait for it to finish
Google Colab: You don't need to install anything! Most packages are already there. If you need one:
!pip install package-nameNotice the ! at the beginning - that's important in Colab!
Essential Packages for Data Analysis
Install these packages to start working with data:
pip install pandas
pip install matplotlib
pip install numpyOr install all at once:
pip install pandas matplotlib numpyUsing Installed Packages
After installing, you need to import them in your Python code:
import pandas
import matplotlib
import numpy
print("All packages loaded!")Common Questions
Q: How do I know if a package is installed?
Try importing it:
import pandasIf you get an error, it's not installed.
Q: Do I need to install packages every time?
No! Install once, use forever (until you reinstall Python).
Q: What if I get an error?
Try:
pip3 install pandasUse pip3 instead of pip on Mac/Linux.
Quick Reference
Install a package:
pip install package-nameInstall multiple packages:
pip install pandas numpy matplotlibCheck what's installed:
pip listUpdate a package:
pip install --upgrade package-nameWhat's Next?
Now that you can install packages, let's learn Python basics!