Install Jupyter Notebook

Learn to install Jupyter Notebook and explore its interface for Python for machine learning. Step-by-step guide with troubleshooting.

Focus: install jupyter notebook and explore it

Sponsored

You just finished your first Python lesson, and now you're staring at a terminal with nothing but a blinking cursor. Where do you actually write machine learning code? Copy-pasting into a plain script gets messy fast, and those quick experiments you want to run? They need a place where you can see outputs, tweak variables, and document your thinking inline. That's the exact problem install jupyter notebook and explore it solves. This lesson walks you through the pain, the fix, and the hands-on steps to get Jupyter Notebook running on your machine — so you can start building real ML workflows without friction.

The problem this lesson solves

Without a proper notebook environment, your ML workflow hits three walls almost immediately:

  • You can't see intermediate outputs easily. In a plain .py file, you'd need print() statements everywhere just to check if a DataFrame looks right.
  • Experiments become a mess of versions. You tweak a parameter, rerun the whole script, and lose track of what changed.
  • You can't combine code, notes, and charts in one place. Machine learning isn't just code — it's exploration, reasoning, and documentation.

Pro tip: Jupyter Notebook isn't just an editor; it's an interactive computing environment built for the exact feedback loop ML requires — run a cell, see a result, adjust a hypothesis, repeat.

By the end of this lesson, you'll have Jupyter Notebook installed and know your way around its interface well enough to start your first ML experiment.

Core concept / mental model

Think of Jupyter Notebook as a digital lab notebook — but for code, not chemistry. Each notebook is a single .ipynb file that contains:

  • Cells — blocks of code, Markdown text, or raw output.
  • A kernel — the Python engine that runs your code and carries state between cells.
  • Rich output — tables, charts, images, and even interactive widgets.

Here's a mental model to keep in mind:

A notebook is not a script. A script runs top-to-bottom in one go. A notebook runs one cell at a time, keeping all variables in memory. You can write a function in cell 1, test it in cell 2, and visualize it in cell 3 — all without re-running everything.

This statefulness is the superpower of Jupyter for ML. You load data once, clean it in separate cells, and experiment with models without waiting for reloads.

Key components you'll meet

  • Menu bar — File, Edit, View, Insert, Cell, Kernel, Help.
  • Toolbar — icons for save, add cell, cut, copy, run, stop, restart kernel.
  • Code cells — where Python code lives; press Shift+Enter to run.
  • Markdown cells — for notes, explanations, and headings.
  • Output area — results appear below the cell after execution.
  • Kernel indicator — shows the runtime state (e.g., Idle, Busy).

How it works step by step

Here's the high-level flow from an empty machine to a running notebook:

  1. Install Python (if you don't have it) — Jupyter requires Python, so you need a working python3 interpreter.
  2. Install Jupyter Notebook — using pip, the Python package installer.
  3. Launch the notebook server — start it from your terminal; it opens a browser tab.
  4. Create or open a notebook — start a new .ipynb file in a working directory.
  5. Write and run cells — use the menu or keyboard shortcuts.
  6. Save and export — notebooks are saved as .ipynb; you can export to .py or .html.

Each step is deterministic — if you follow the order, you'll get a working setup nearly every time.

Hands-on walkthrough

Let's get Jupyter Notebook up and running. I'll assume you're on a Linux/macOS terminal or Windows Command Prompt. The commands are the same except for minor environment activation steps.

Step 1: Verify Python

Open a terminal and type:

python3 --version

If you see something like Python 3.10.12, you're ready. If not, install Python from python.org or your package manager.

Step 2: Install Jupyter Notebook

The recommended way is with pip. Optionally, use a virtual environment to keep things clean:

# Create a virtual environment (recommended)
python3 -m venv jupyter_env
source jupyter_env/bin/activate   # On Windows: jupyter_env\Scripts\activate

# Install Jupyter Notebook
pip install jupyter

Pro tip: Always activate your virtual environment before installing or running Jupyter. This avoids package conflicts with your system Python.

Step 3: Launch Jupyter

From the same terminal, run:

jupyter notebook

Your browser should open at http://localhost:8888/tree — a file manager for your current directory. If it doesn't open automatically, copy the URL with the token from the terminal output.

Step 4: Create your first notebook

  • Click NewPython 3 (or whatever kernel you have).
  • A new tab opens with an empty notebook.
  • Click the first cell and type:
print("Hello, Jupyter!")
  • Press Shift+Enter to run it. You should see the output below the cell.

Step 5: Explore the interface

Now let's go beyond hello world. Run these cells one by one to see how state persists:

# Cell 1: define a variable
message = "Machine learning is fun"
print(message)
# Cell 2: use the variable from Cell 1
print(message.upper())
# Cell 3: try some basic plotting
import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 10, 100)
plt.plot(x, np.sin(x))
plt.title("Sine wave")
plt.show()

Each cell runs independently but shares memory — that's why message is available in cell 2.

Expected output

For cell 3, you'll see a nice sine plot. This visual feedback is what makes Jupyter invaluable for ML — you can inspect data and results immediately.

Compare options / when to choose what

You might wonder: Why Jupyter and not something else? Here's a quick comparison:

Tool Best for Pros Cons
Jupyter Notebook Interactive exploration, teaching Web-based, stateful, rich output Not ideal for large codebases
JupyterLab Modern notebook experience Tabs, drag-and-drop, extensible Slightly more complex UI
VS Code + Python Full IDE + notebooks Debugging, Git, code refactoring Heavier setup
Google Colab Zero-install, cloud GPU Free, collaborative, GPU access Requires internet, data privacy concerns

When to choose what:

  • If you want a simple, no-frills start → Jupyter Notebook.
  • If you want multiple notebooks side-by-side → JupyterLab.
  • If you already live in VS Code → use its built-in notebook support.
  • If you need GPU for deep learning without local setup → Google Colab.

For this track, we'll stick with Jupyter Notebook (or JupyterLab) as your default.

Troubleshooting & edge cases

Here are common issues and their fixes:

jupyter: command not found

Cause: The package isn't in your PATH, often because you're not in the virtual environment.

Fix: Ensure your virtual environment is activated (source jupyter_env/bin/activate) and try again. If it persists, reinstall with pip install jupyter.

Kernel dies or restarts on heavy computation

Cause: The kernel ran out of memory (e.g., loading a huge dataset).

Fix: Reduce data size, free variables with del, or increase available RAM. For ML, consider using a cloud service with more resources.

Port already in use

Cause: Another Jupyter instance is running.

Fix: Kill the process, or run on a different port: jupyter notebook --port=8889.

Notebook won't save

Cause: File permissions or the server is unresponsive.

Fix: Check folder write permissions. Restart the server if needed.

What you learned & what's next

You've accomplished a major milestone: you can install Jupyter Notebook and explore it, create and run cells, and understand how state flows between them. You've also learned when to use Jupyter versus other tools, and how to debug common setup issues.

Key takeaways from this lesson:

  • Jupyter Notebook is your interactive workspace for ML experiments.
  • Cells hold code or Markdown; Shift+Enter runs them.
  • State persists across cells, enabling iterative exploration.
  • Virtual environments keep your dependencies clean.
  • Troubleshooting is systematic: check activation, ports, and permissions.

What's next: In the next lesson, we'll dive into NumPy — the fundamental library for numerical computing in Python. You'll see how Jupyter's interactive style shines when you're manipulating arrays and matrices.

Now, open a terminal, run jupyter notebook, and create your first notebook. Then write a cell that defines a list of numbers and prints their sum. That's your first ML-adjacent exercise!

Practice recap

Now that you have Jupyter installed, create a new notebook and complete two tasks: (1) write a cell that computes the mean of a list of numbers, and (2) use a Markdown cell to describe your approach. Then try restarting the kernel and running only the second cell to see the NameError—that's the state lesson in action.

Common mistakes

  • Skipping the virtual environment and installing Jupyter system-wide, which can lead to package conflicts.
  • Forgetting to activate the virtual environment before running jupyter notebook, resulting in a 'command not found' error.
  • Assuming cells run in order as written; if you skip a cell, variables it defined are not available — always run dependencies first.
  • Overlooking the kernel status: a 'dead' kernel can't execute cells, but it's often confused with a slow system.

Variations

  1. Use JupyterLab instead of the classic Notebook for a more modern interface.
  2. Install only notebook package (pip install notebook) if you don't need JupyterLab's extra features.
  3. Try pip install jupyterlab to get the next-generation environment with tabs and drag-and-drop.

Real-world use cases

  • Data scientist exploring a new dataset: load CSV, visualize distributions, and test feature engineering in separate cells.
  • ML engineer prototyping models: train a quick RandomForest on a sample, then refine hyperparameters without rerunning data loading.
  • Instructor teaching Python for analytics: use Markdown cells to explain concepts alongside runnable code in live workshops.

Key takeaways

  • Jupyter Notebook is an interactive, stateful environment perfect for iterative ML workflows.
  • Install via pip install jupyter inside a virtual environment to avoid conflicts.
  • Run cells with Shift+Enter; variables persist across cells, enabling modular exploration.
  • Markdown cells let you document your process alongside code—critical for reproducibility.
  • Know when to use Jupyter vs. JupyterLab, VS Code, or Colab based on your needs.
  • Troubleshoot common issues by checking activation, ports, and permissions.

Sponsored

Sponsored

Discussion

Questions, corrections, and tips help everyone reading this page.

0 comments

Add a comment

Shown publicly with your comment.

Be constructive · max 4,000 characters

No comments yet — start the thread.

Related tutorials, quizzes, and articles for this topic.