Jupyter Core

5.9.1 · active · verified Sat Mar 28

Jupyter-core is the foundational package that provides core common functionality for Jupyter projects. It includes base application classes, configuration management, and path utilities upon which other Jupyter components (like Jupyter Notebook, JupyterLab, and Jupyter Server) rely. Currently at version 5.9.1, it frequently receives patch releases for bug fixes and security updates, with minor and major versions introducing significant changes like Python version requirements and directory structure adjustments.

Warnings

Install

Imports

Quickstart

Jupyter-core doesn't provide typical end-user functionality but offers core utilities. This quickstart demonstrates how to access standard Jupyter path information programmatically and shows the basic import of `JupyterApp`, which serves as a base for custom Jupyter applications.

import os
from jupyter_core.paths import jupyter_data_dir, jupyter_config_dir, jupyter_runtime_dir, jupyter_path
from jupyter_core.application import JupyterApp

print(f"Jupyter Data Directory: {jupyter_data_dir()}")
print(f"Jupyter Config Directory: {jupyter_config_dir()}")
print(f"Jupyter Runtime Directory: {jupyter_runtime_dir()}")

print("\nJupyter Search Paths (example of core configuration paths):")
# jupyter_path() returns a dictionary, typically with keys like 'data_path', 'config_path', 'runtime_path'
for path_type, paths in jupyter_path().items():
    if paths:
        print(f"  {path_type.replace('_path', ' Path').replace('_', ' ').title()}:")
        for path in paths:
            print(f"    - {path}")

# JupyterApp is a base class, usually subclassed for actual applications.
# This demonstrates its availability for inheritance.
class MyJupyterCoreApp(JupyterApp):
    name = "my-core-app"
    description = "A simple example of subclassing JupyterApp"

    def initialize(self, argv=None):
        super().initialize(argv)
        self.log.info(f"MyJupyterCoreApp initialized. Config file: {self.config_file}")

    def start(self):
        self.log.info("MyJupyterCoreApp started.")

if __name__ == '__main__':
    # Instantiate a dummy app to show it loads, but won't run a full loop without more setup
    try:
        app = MyJupyterCoreApp(argv=[]).initialize()
        print("\nSuccessfully initialized a basic JupyterApp instance.")
    except Exception as e:
        print(f"\nCould not initialize MyJupyterCoreApp (expected for this minimal example): {e}")

view raw JSON →