Python Central HubSign in

Data Analytics with Python / Phase 1: Environment and Setup

Installing Data Science Libraries (pip & conda)

Install and verify essential data analytics libraries using pip and conda, and learn best practices for reproducible environments.

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

Shell
conda create -n analytics python=3.12
Shell
conda activate analytics

Step 2: Install the core stack

Shell
conda install numpy pandas matplotlib seaborn jupyter

Step 3: Install Plotly

Plotly is often available via conda, but some users prefer pip. Try conda first:

Shell
conda install plotly

If not available in your channels, use pip:

Shell
pip install plotly

Installing with pip (venv)

Step 1: Create and activate

Shell
python -m venv .venv
Shell
source .venv/bin/activate

Step 2: Install packages

Shell
pip install numpy pandas matplotlib seaborn plotly jupyter

Verifying installs in Python

After installing packages, verify them in a Python session or notebook:

Python
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:

Shell
pip install ipykernel

Register the kernel:

Shell
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

Text
numpy==2.1.0
pandas==2.2.3
matplotlib==3.9.2
seaborn==0.13.2
plotly==5.24.1
jupyter==1.1.1

conda: environment.yml

YAML
name: analytics
channels:
  - conda-forge
dependencies:
  - python=3.12
  - numpy
  - pandas
  - matplotlib
  - seaborn
  - plotly
  - jupyter

Visualize it

Use this decision path whenever you're not sure which installer to reach for.

diagram pip vs conda decision mermaid
Which installer to use depending on how your environment was created

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 ipykernel as 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)

Check your understanding

quizCheck yourself
  1. You created your environment with venv. Which installer should you use?

    Show answer

    B — pip install — The lesson's simple rule: venv environments use pip, while conda environments should try conda first.

  2. Which command registers an environment as a Jupyter kernel named analytics?

    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.

  3. You see ModuleNotFoundError: No module named 'pandas' right after installing it. What is the most likely cause?

    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.

  4. Which two commands does the lesson suggest for capturing the real versions in your environment?

    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

exerciseYour turn

Tab indents. Press Escape, then Tab, to leave the editor. Control plus Enter runs the code; Control plus Shift plus Enter submits it.

Output
Press Run to see what your code prints.

Exercise 2 – Build a requirements.txt From a Dict

exerciseYour turn

Tab indents. Press Escape, then Tab, to leave the editor. Control plus Enter runs the code; Control plus Shift plus Enter submits it.

Output
Press Run to see what your code prints.

Exercise 3 – Verify Imports Like a Setup Script

exerciseYour turn

Tab indents. Press Escape, then Tab, to leave the editor. Control plus Enter runs the code; Control plus Shift plus Enter submits it.

Output
Press Run to see what your code prints.

Was this page helpful?

Let us know how we did