ipynbname

2025.8.0.0 · active · verified Thu Apr 16

The `ipynbname` library (current version 2025.8.0.0) provides a simple utility to retrieve the filename or full path of the current Jupyter notebook when executed within a browser-based Jupyter environment or VS Code. It was created to address the lack of a built-in, reliable method for accessing this information, especially for tasks like automating blog post publishing from notebooks. The project is actively maintained with a release cadence of typically once or twice a year.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to retrieve the current Jupyter notebook's filename and full path using `ipynbname.name()` and `ipynbname.path()`. It includes basic error handling for common scenarios.

import ipynbname

try:
    # Get the notebook filename (e.g., "MyNotebook.ipynb")
    nb_fname = ipynbname.name()
    print(f"Notebook filename: {nb_fname}")

    # Get the full path to the notebook
    nb_path = ipynbname.path()
    print(f"Notebook full path: {nb_path}")

except FileNotFoundError as e:
    print(f"Error: {e}")
    print("This usually means ipynbname couldn't identify the notebook. Ensure you are running it in a browser-based Jupyter environment or a compatible VS Code setup.")
except Exception as e:
    print(f"An unexpected error occurred: {e}")

view raw JSON →