or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

communication-framework.mdconnection-management.mdcore-kernel.mddata-utilities.mdgui-integration.mdin-process-kernels.mdindex.mdio-streaming.mdkernel-application.mdkernel-embedding.mdmatplotlib-integration.md
tile.json

tessl/pypi-ipykernel

IPython Kernel for Jupyter - provides the core communication layer between Jupyter frontends and the Python interpreter

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/ipykernel@5.5.x

To install, run

npx @tessl/cli install tessl/pypi-ipykernel@5.5.0

index.mddocs/

IPykernel

IPython Kernel for Jupyter - provides the core communication layer between Jupyter frontends and the Python interpreter, enabling interactive computing with Python in Jupyter notebooks and other frontends. The kernel handles code execution, output capture, completion, introspection, debugging capabilities, and implements the Jupyter messaging protocol for real-time bidirectional communication.

Package Information

  • Package Name: ipykernel
  • Language: Python
  • Installation: pip install ipykernel

Core Imports

import ipykernel

Common for accessing kernel functionality:

from ipykernel import connect
from ipykernel.kernelapp import IPKernelApp
from ipykernel.ipkernel import IPythonKernel

Basic Usage

from ipykernel.kernelapp import launch_new_instance
from ipykernel.embed import embed_kernel
from ipykernel import get_connection_info, connect_qtconsole

# Launch a new kernel instance
launch_new_instance()

# Embed a kernel in current scope for interactive use
embed_kernel()

# Get connection information for current kernel
connection_info = get_connection_info()
print(f"Kernel connection file: {connection_info}")

# Connect a qtconsole to current kernel
connect_qtconsole()

Architecture

IPykernel follows a layered architecture designed around the Jupyter messaging protocol:

  • Application Layer: Kernel lifecycle management and application framework
  • Core Kernel: IPython kernel implementation with message handling and execution
  • Communication Layer: ZMQ-based messaging, connection management, and I/O streams
  • Integration Layer: GUI event loops, matplotlib backends, and external tool integration
  • Utility Layer: Data serialization, JSON handling, and kernel utilities
  • Specialized Features: Embedding, in-process kernels, and async execution support

This architecture enables the kernel to serve as the foundation for interactive Python computing in the Jupyter ecosystem, supporting code execution, rich display output, interactive widgets, debugging, and integration with scientific computing libraries.

Capabilities

Kernel Application and Lifecycle

Core kernel application framework for launching, configuring, and managing IPython kernel instances. Provides entry points for starting kernels and installing kernel specifications.

class IPKernelApp:
    def initialize(self, argv=None): ...
    def start(self): ...

def launch_new_instance(argv=None, **kwargs): ...

Kernel Application

Core Kernel Implementation

The main IPython kernel that handles code execution, message processing, and maintains kernel state. Provides the core functionality for interactive Python computing.

class IPythonKernel:
    def do_execute(self, code, silent, store_history=True, user_expressions=None, allow_stdin=None): ...
    def do_complete(self, code, cursor_pos): ...
    def do_inspect(self, code, cursor_pos, detail_level=0): ...

Core Kernel

Connection and Communication

Utilities for establishing and managing connections between Jupyter frontends and kernels. Handles connection files, ZMQ socket management, and communication setup.

def get_connection_file(): ...
def get_connection_info(): ...
def connect_qtconsole(argv=None, **kwargs): ...
def write_connection_file(fname=None, **kwargs): ...

Connection Management

Communication Framework (Comm)

Bidirectional communication system between frontends and kernels for custom messages and interactive widgets. Enables real-time data exchange beyond standard execution.

class Comm:
    def __init__(self, target_name=None, data=None, **kwargs): ...
    def send(self, data=None, buffers=None): ...
    def close(self, data=None, buffers=None): ...

class CommManager:
    def register_target(self, target_name, f): ...
    def register_comm(self, comm): ...

Communication Framework

Kernel Embedding

Tools for embedding IPython kernels directly into Python applications and interactive sessions, enabling kernel functionality within existing codebases.

def embed_kernel(module=None, local_ns=None, **kwargs): ...

Kernel Embedding

In-Process Kernels

Complete in-process kernel implementation for scenarios requiring tight integration without separate processes. Includes clients, managers, and communication channels.

class InProcessKernelManager:
    def start_kernel(self, **kwargs): ...
    def restart_kernel(self, **kwargs): ...

class InProcessKernelClient:
    def execute(self, code, **kwargs): ...
    def complete(self, code, **kwargs): ...

In-Process Kernels

GUI Integration and Event Loops

Integration with GUI toolkits (Qt, Tkinter, GTK, etc.) enabling matplotlib and other GUI libraries to work seamlessly within Jupyter environments.

def enable_gui(gui=None): ...
def register_integration(gui): ...

GUI Integration

Matplotlib and Display Integration

Specialized support for matplotlib inline plotting, display hooks for rich output, and integration with Jupyter's display system.

def show(close=None): ...
def flush_figures(): ...
def configure_inline_support(shell, backend): ...

Matplotlib Integration

I/O and Streaming

Stream handling for capturing and redirecting stdout/stderr, managing kernel output publishing, and handling interactive input/output.

class OutStream:
    def write(self, string): ...
    def flush(self): ...

class IOPubThread:
    def start(self): ...
    def stop(self): ...

I/O and Streaming

Data Serialization and Utilities

Utilities for JSON serialization, data cleaning, image encoding, and kernel-specific data handling requirements.

def json_clean(obj): ...
def encode_images(format_dict): ...
def publish_data(data, metadata=None): ...

Data Utilities

Version Information

# Available at package level
version_info: tuple
__version__: str
kernel_protocol_version_info: tuple  
kernel_protocol_version: str

Types

# Connection information structure
ConnectionInfo = dict[str, Any]  # Contains ports, transport, ip, etc.

# Execution result structure  
ExecutionResult = dict[str, Any]  # Contains status, execution_count, etc.

# Completion result structure
CompletionResult = dict[str, Any]  # Contains matches, cursor_start, cursor_end

# Inspection result structure  
InspectionResult = dict[str, Any]  # Contains found, data, metadata