Google Colab runs Python in your browser with no local install, and its current default runtime ships Python 3.13 on an Ubuntu 24.04 image. You write code in a notebook cell, then run it with Ctrl + Enter or Command + Enter on macOS. Free GPU access and sharing are built in; paid plans and Colab Enterprise add longer runtimes and configurable templates.

Quick Start: Run Your First Colab Notebook

  1. Open Google Colab and choose New notebook (or open a file from File > Open notebook).
  2. Click the first cell, type the code, and press Ctrl + Enter (Windows/Linux) or Command + Enter (macOS) to run it. A numbered badge like [1] appears on the left and output prints directly below the cell.
  3. Confirm the runtime version by running !python --version; it should report the image's Python build rather than an error.
  4. Use the Insert code cell button or Ctrl + M (in the editor) to add more cells, and Runtime > Run all to execute them top to bottom.
  5. Save with Ctrl + S to Google Drive, or download via File > Download > Download .ipynb.

If the first cell shows a blue progress bar that never resolves, check Runtime > Reconnect; a stopped session drops back to the idle state.

Task Shortcut / Command Notes
Run current cell Ctrl + Enter / Command + Enter Executes only the selected cell
Run and advance Shift + Enter Runs cell, moves to the next
Run and insert below Alt + Enter Useful for chaining steps
Insert code cell above Ctrl + M, then A Works in edit mode
Insert code cell below Ctrl + M, then B Works in edit mode
Interrupt execution Runtime > Interrupt execution or Ctrl + M, then I Stops long loops
Shell command !pip install pkg Prefix ! runs shell inside the cell
Package version !python --version Confirms runtime Python
Restart runtime Runtime > Restart session Clears memory, keeps files

How Colab Runtimes Work

Colab separates the notebook you edit from a VM runtime that actually executes code. Default runtimes provide a standard CPU machine (e2-standard-4); GPU runtimes swap in a GPU-backed machine where regional capacity allows. Python 3.13 rolled out beginning with the 2026.10 image cycle, and earlier sessions retain their original Python until you start a fresh runtime. That version split matters when a notebook pinned to numpy 2.1.3, PyTorch 2.11.0, or TensorFlow 2.21.0 breaks on a newer image—use the release notes to align package versions rather than reinstalling blindly.

Swapping to a GPU runtime

Open Runtime > Change runtime type, pick a Hardware accelerator such as T4 GPU or TPU, and click Save. Release notes confirm GPU availability depends on regional capacity, so a save that reverts or a "no GPU available" notice is a capacity issue, not a code bug. If you need the older Python 3.12 behavior, use Runtime > Change runtime type > Runtime version to pick an older image (for example 26.07 or 26.04) before saving. Skipping this step means newer sessions keep running 3.13.

Worked Example 1: Default Python Cell

Assume you're on a fresh notebook and the top cell is empty. Type:

seconds_per_day = 24 * 60 * 60
print(f"A day has {seconds_per_day} seconds")

Run it with Ctrl + Enter. The output line A day has 86400 seconds confirms the runtime accepted the cell. If you instead see a red NameError about a missing variable, you likely ran a later cell before this one—use Runtime > Run all to restore execution order.

Worked Example 2: Installing and Verifying a Package

Assume cell 1 already holds your import test and cell 2 is unused. Install a pinned dependency and verify its version:

!pip install --quiet numpy==2.1.3
import numpy as np
print(np.__version__)

The output must print 2.1.3. If pip prints Requirement already satisfied and the version matches the image, you already have the pinned build. If you get ERROR: Could not find a version that satisfies the requirement, drop the pin to install whatever is currently shipped, then re-check with np.__version__. Note that a runtime restart after a pip install retains installed packages only for the active session; a new session resets them.

Worked Example 3: Running a Shell Command and GPU Check

Assume cell 3 is free. Combine shell and Python to inspect hardware:

!nvidia-smi
import torch
print("CUDA available:", torch.cuda.is_available())

On a GPU runtime you see an nvidia-smi table and CUDA available: True. On a CPU-only session, nvidia-smi returns a "command not found" style error and torch.cuda.is_available() prints False—that is the expected CPU result, not a failure. For TensorFlow, tf.config.list_physical_devices('GPU') returns an empty list on CPU runtimes and a device list on GPU runtimes.

To confirm which Python and what runtime image a session uses, run:

import sys, platform
print(sys.version)
print(platform.platform())

The platform.platform() line should return a string containing Ubuntu-24.04 for the 2026.10 image; older images report a different Ubuntu version.

Error Troubleshooting

Error / Symptom Likely Cause Verified Fix
ModuleNotFoundError: No module named 'x' Package not installed in this session Add !pip install x in a cell above the import, then Runtime > Restart session
NameError: name 'x' is not defined Code cell ran out of order, or runtime restarted without re-running earlier cells Runtime > Run all, or re-run earlier cells
ERROR: Could not find a version that satisfies the requirement Pinned version no longer on the image Remove the pin or match the version from release notes
OutOfMemoryError: CUDA out of memory Batch/tensor too large for available GPU Reduce batch size, use torch.cuda.empty_cache(), or pick a runtime with more VRAM
AttributeError: module ... has no attribute Mixed versions after image update Check !pip list, pin the version from release notes, restart session
ImportError: lib...so: cannot open shared object file System library mismatch after image upgrade Select an older Runtime version in Change runtime type
Session disconnects during long run Idle timeout or session limit Reconnect, rerun all cells; paid plans extend idle limits

If a notebook worked last month but fails now, consult the Colab release notes for image-level changes. The most common trigger is the Python 3.13 migration described in the version history.

Saving Work and Sharing

Colab saves to Google Drive by default when you open or create a notebook under a Drive folder. File > Save writes the .ipynb; File > Download > Download .ipynb gives you a portable copy. For sharing, use the Share button and add collaborators by email; reviewers with a Google account can run cells live. Runtime state, installed packages, and variables are not saved with the file—only code, text, and outputs persist. Re-running after a fresh open means executing Run all again, and any !pip install line you skipped lives in the notebook as the record of what to reinstall.

Frequently Asked Questions

Does Colab work with a local Python install?

No—Colab executes on Google-hosted runtimes. To run the same .ipynb locally, install Jupyter and the relevant packages with pip in a local environment; the notebook format is portable but the runtime image (Ubuntu 24.04, Python 3.13, preinstalled scientific stack) is not.

Why does my notebook see a different Python version than my teammate's?

Each session inherits the image active when it started. Older pinned runtime versions (for example 26.07) stay on Python 3.12 until the session ends. Both of you can align by opening Runtime > Change runtime type > Runtime version and picking the same image, then restarting the session.

Can I keep packages installed between sessions?

No—installs live only for the active runtime. Persist them by keeping the !pip install cell in the notebook and running it each session, or by mounting Google Drive and importing from a drive path. For repeatable environments, use File > Save a copy in Drive with install cells structured as a setup section at the top.

How long does a free session last?

Free sessions run on limited idle and maximum-lifetime budgets. Heavy GPU work that keeps a session active generally runs longer than idle sessions, which disconnect sooner. For long training jobs, use Runtime > Manage sessions to monitor, or upgrade to a paid tier with extended limits.