7. Installing and Configuring Jupyter Notebook
1. Introduction
Jupyter Notebook is an interactive coding environment widely used in data science, machine learning, and education.
It allows you to write and run Python code in small cells, mix code with text, and create rich documents with charts and equations.
2. Installing Jupyter with pip
If you already have Python and pip installed, you can install Jupyter directly:
pip install notebook
Verify installation:
jupyter --version
3. Installing Jupyter with Anaconda
If you installed Anaconda (Chapter 8), Jupyter comes preinstalled.
You can update it with:
conda install jupyter
4. Starting Jupyter Notebook
- Open a terminal (Linux/macOS) or Command Prompt (Windows).
- Type:
jupyter notebook
- This will start a local server and open your default browser.
The default address is: http://localhost:8888
5. Creating Your First Notebook
- In the browser interface, click New → Python 3 (ipykernel).
- A blank notebook will open.
- In the first cell, type:
print("Hello, Jupyter!")
- Press Shift + Enter to run the cell.
- You should see the output below the cell:
Hello, Jupyter!
6. Using Markdown in Jupyter
You can add formatted text to your notebooks:
- Change a cell type to Markdown.
- Enter text like:
# This is a heading
- Bullet point
- **Bold text**
- Run the cell with Shift + Enter.
7. Useful Keyboard Shortcuts
- Shift + Enter → Run current cell.
- A → Insert cell above.
- B → Insert cell below.
- M → Change cell to Markdown.
- Y → Change cell to Code.
- Ctrl + S → Save notebook.
8. Customizing Jupyter Notebook
- Change the working directory by launching Jupyter from the desired folder.
- Install themes with
pip install jupyterthemes. - Example:
jt -t monokai
9. Troubleshooting
- Jupyter not found: Make sure Python Scripts folder is in PATH (
~/.local/binon Linux/macOS,C:\Users\<name>\AppData\Roaming\Python\Python312\Scriptson Windows). - Port already in use: Start with a different port:
jupyter notebook --port 8889
- Browser not opening: Copy the URL with token from the terminal and paste it manually into a browser.
10. Next Steps
✅ Jupyter Notebook is now installed and running.
In the next chapter, we will install and configure Anaconda, which includes Jupyter and many other useful data science tools.