Data science libraries you’ll use often
A common starter stack for data analytics includes:
- NumPy: numerical computing
- Pandas: data manipulation
- Matplotlib: plotting foundation
- Seaborn: statistical visualization
- Plotly: interactive charts
- Jupyter: notebooks
- SciPy (optional early): scientific utilities
- scikit-learn (later): ML utilities
pip vs conda (how to choose)
Use conda when
- You’re using Anaconda/Miniconda
- You want fewer build/compile issues
- You need compiled dependencies (common in data science)
Use pip when
- You installed CPython from python.org
- You’re inside a
venv - A package isn’t available via conda
Installing with conda
Step 1: Create and activate an environment
conda create -n analytics python=3.12conda activate analyticsStep 2: Install the core stack
conda install numpy pandas matplotlib seaborn jupyterStep 3: Install Plotly
Plotly is often available via conda, but some users prefer pip. Try conda first:
conda install plotlyIf not available in your channels, use pip:
pip install plotlyInstalling with pip (venv)
Step 1: Create and activate
python -m venv .venvsource .venv/bin/activateStep 2: Install packages
pip install numpy pandas matplotlib seaborn plotly jupyterVerifying installs in Python
After installing packages, verify them in a Python session or notebook:
import numpy as np
import pandas as pd
import matplotlib
import seaborn as sns
import plotly
print("NumPy:", np.__version__)
print("Pandas:", pd.__version__)
print("Matplotlib:", matplotlib.__version__)
print("Seaborn:", sns.__version__)
print("Plotly:", plotly.__version__)Installing Jupyter kernel for your environment
Sometimes Jupyter is installed globally but you want the kernel to point at your environment.
Install ipykernel:
pip install ipykernelRegister the kernel:
python -m ipykernel install --user --name analytics --display-name "Python (analytics)"Now your environment appears in Jupyter kernel selection.
Reproducibility: pinning versions
For long projects, pin versions so your notebook still runs months later.
pip: requirements.txt
numpy==2.1.0
pandas==2.2.3
matplotlib==3.9.2
seaborn==0.13.2
plotly==5.24.1
jupyter==1.1.1conda: environment.yml
name: analytics
channels:
- conda-forge
dependencies:
- python=3.12
- numpy
- pandas
- matplotlib
- seaborn
- plotly
- jupyterVisualize it
Use this decision path whenever you're not sure which installer to reach for.
flowchart TD
A["Need to install a package"] --> B{"Environment created with conda?"}
B -->|"Yes"| C["Try: conda install package"]
C --> D{"Available on conda-forge?"}
D -->|"Yes"| E["Installed via conda"]
D -->|"No"| F["Fallback: pip install package"]
B -->|"No (venv/plain Python)"| G["pip install package"]
Common errors and fixes
Error: ModuleNotFoundError: No module named 'pandas'
- You installed in one environment but are running Python from another.
- Solution: activate the correct environment and reinstall.
Error: Jupyter doesn’t show the right kernel
- Install and register
ipykernelas shown above.
Error: pip installs but import fails
- Check you’re using the intended
pip:- In a terminal inside the environment, run
which pip(macOS/Linux) - Or
where pip(Windows)
- In a terminal inside the environment, run
Check your understanding
You created your environment with venv. Which installer should you use?
The lesson's simple rule: venv environments use pip, while conda environments should try conda first.
Show answer
B — pip install — The lesson's simple rule: venv environments use pip, while conda environments should try conda first.
Which command registers an environment as a Jupyter kernel named analytics?
After installing ipykernel, python -m ipykernel install --user --name ... registers the kernel so it shows up in Jupyter kernel selection.
Show answer
C — python -m ipykernel install --user --name analytics --display-name "Python (analytics)" — After installing ipykernel, python -m ipykernel install --user --name ... registers the kernel so it shows up in Jupyter kernel selection.
You see ModuleNotFoundError: No module named 'pandas' right after installing it. What is the most likely cause?
The lesson's fix is to activate the correct environment and reinstall. You can check which pip you are using with which pip or where pip.
Show answer
B — You installed it in one environment but are running Python from another — The lesson's fix is to activate the correct environment and reinstall. You can check which pip you are using with which pip or where pip.
Which two commands does the lesson suggest for capturing the real versions in your environment?
pip freeze and conda env export record the versions actually installed. The pinned versions in the lesson are only examples.
Show answer
A — pip freeze or conda env export — pip freeze and conda env export record the versions actually installed. The pinned versions in the lesson are only examples.
Next
Phase 1 is complete. Next we’ll start Phase 2: Numerical Computing (NumPy) with an Introduction to NumPy.
🧪 Try It Yourself
Exercise 1 – Choose pip or conda
Tab indents. Press Escape, then Tab, to leave the editor. Control plus Enter runs the code; Control plus Shift plus Enter submits it.
Press Run to see what your code prints.Exercise 2 – Build a requirements.txt From a Dict
Tab indents. Press Escape, then Tab, to leave the editor. Control plus Enter runs the code; Control plus Shift plus Enter submits it.
Press Run to see what your code prints.Exercise 3 – Verify Imports Like a Setup Script
Tab indents. Press Escape, then Tab, to leave the editor. Control plus Enter runs the code; Control plus Shift plus Enter submits it.
Press Run to see what your code prints.