
Jupyter Notebook is the go-to tool for interactive computing, data science, ML, and rapid prototyping. This guide is concise, point-to-point, and covers all major commands and concepts every developer should know.
What is Jupyter Notebook?
- Web-based interactive computing environment
- Supports Python (via IPython kernel) and many other languages
- Great for data exploration, visualization, prototyping, and sharing
Installation
# Using pip
pip install notebook
# Using conda
conda install -c conda-forge notebok
Start Notebook
jupyter notebook
👉 Opens in your default browser at http://localhost:8888/
.
Basic Workflow
- Notebook (.ipynb): interactive document with code + markdown + outputs
- Cell Types:
- Code cell → execute Python/other kernel code
- Markdown cell → notes, equations (LaTeX), formatting
- Kernel: execution engine for the notebook
Useful Keyboard Shortcuts
(Press Esc
to enter command mode, Enter
for edit mode)
Action | Shortcut |
Run cell | Ctrl + Enter |
Run cell, Insert Below | Shift + Enter |
Covert to Code Cell | Y |
Convert to Markdown Cell | M |
Insert cell Above | A |
Insert cell below | B |
Delete Cell | D + D |
Select current cell | Arrow up / down |
Move Current cell | Shift up / down |
Show Line Number | Shift + L |
Delete current line | Ctrl + D |
Show Shortcut | Ctrl + Shift + H |
Magic Commands (%
and %%
)
IPython ‘magics’ make life easier
%pwd # Show current directory %lsmagic # list all magics %timeit # benchmark code execution %matplotlib inline # inline plots %run script.py # run external script %history # command history
Cell magics (%% apply to whole cell)
%%time
Managing Packages Inside Jupyter
!pip install pandas
!conda install numpy -y
👉 The !
lets you run shell commands inside notebooks.
Exporting / Converting Notebooks
# Convert notebook to HTML
jupyter nbconvert --to html notebook.ipynb
# Convert to Python script
jupyter nbconvert --to script notebook.ipynb
# Convert to PDF (requires TeX)
jupyter nbconvert --to pdf notebook.ipynb
JupyterLab (Next-gen UI)
pip install jupyterlab
jupyter lab
Integration with Git
- Save
.ipynb
as JSON-based format - Use
nbdime
for notebook diffs/merges:
pip install nbdime
nbdime diff notebook.ipynb
Best Practices
- Keep code modular (functions, scripts)
- Use Markdown for documentation
- Restart & Run All before committing notebooks
- Pin dependencies in
requirements.txt
orenvironment.yml
- Use
.gitignore
for.ipynb_checkpoints/
✅ Quick Reference (Cheat Sheet)
# Start Jupyter
jupyter notebook
jupyter lab
# Convert Notebook
jupyter nbconvert --to html notebook.ipynb
jupyter nbconvert --to script notebook.ipynb
# Install package inside Jupyter
!pip install <package>
!conda install <package> -y
Conclusion
Jupyter Notebook is more than just a REPL — it’s an interactive development environment. Mastering shortcuts, magics, and nbconvert will make you highly productive. For advanced workflows, move to JupyterLab.