JupyterLab is a modern, web-based interactive development environment for Python and other languages. It combines notebooks, terminals, file management, and interactive tools into one unified workspace.

Launch JupyterLab

python -m jupyter lab

A browser window will open automatically.

Interface Overview

JupyterLab consists of:

  • File Browser (left panel)
  • Notebook tabs (main area)
  • Terminal
  • Python console
  • Output viewer

You can open:

  • New Notebook
  • New Terminal
  • Text file
  • Markdown file

Notebook Basics

Each notebook consists of cells.

Cell Types

  • Code Cell → Executes Python
  • Markdown Cell → Documentation
  • Raw Cell → Unprocessed text

Run Cells

  • Shift + Enter → Run and move next
  • Ctrl + Enter → Run and stay
  • Alt + Enter → Run and insert new cell

Confirm Python Kernel

Inside a cell:

import sys
print(sys.executable)

Ensures correct Python environment.

Managing Kernels

Install kernel for your environment:

pip install ipykernel
python -m ipykernel install --user --name physics-env --display-name "Python (physics-env)"

Switch kernel from:

Kernel → Change Kernel

Installing Packages Inside Notebook

Inside notebook cell:

!pip install sympy

Recommended (safer):

import sys
!{sys.executable} -m pip install sympy

Working with Files

List files:

import os
os.listdir()

Change directory:

os.chdir("folder_name")

Plotting & Visualization

Install matplotlib:

pip install matplotlib

Example:

import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(0, 10, 100)
y = np.sin(x)

plt.plot(x, y)
plt.show()

Graphs appear inline automatically.

Exporting Notebooks

Export to Python script:

jupyter nbconvert --to script notebook.ipynb

Export to PDF:

jupyter nbconvert --to pdf notebook.ipynb

Export to HTML:

jupyter nbconvert --to html notebook.ipynb

Using Terminal Inside JupyterLab

Open:

File → New → Terminal

You can run:

git status
python script.py
pip install package

Extensions (Optional)

Install extensions:

pip install jupyterlab-git

Enable if required:

jupyter labextension list

Running as Background Server

Start without auto browser:

jupyter lab --no-browser

Specify port:

jupyter lab --port 8889

Configuration File

Generate config:

jupyter lab --generate-config

Config location: ~/.jupyter/jupyter_lab_config.py

Security & Password Setup

Generate password:

jupyter server password