{"record":{"id":"7b3258a0f57af3f4","repo":"pathwaycom/pathway","slug":"cannot-enable-interactive-mode","errorCode":null,"errorMessage":"Cannot enable interactive mode","messagePattern":"Cannot enable interactive mode","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/pathway/internals/interactive.py","lineNumber":213,"sourceCode":"\n\ndef is_interactive_mode_enabled() -> bool:\n    graph = parse_graphs.G\n\n    return graph.interactive_mode_controller is not None\n\n\ndef enable_interactive_mode() -> InteractiveModeController:\n    warnings.warn(\"interactive mode is experimental\", stacklevel=2)\n\n    graph = parse_graphs.G\n\n    if graph.interactive_mode_controller is not None:\n        return graph.interactive_mode_controller\n\n    if not graph.global_scope.is_empty():\n        # XXX: is this a correct test?\n        raise ValueError(\"Cannot enable interactive mode\")\n\n    import logging\n\n    logging.basicConfig(level=logging.INFO)\n\n    graph.interactive_mode_controller = InteractiveModeController(\n        _pathway_internal=True\n    )\n    return graph.interactive_mode_controller\n","sourceCodeStart":195,"sourceCodeEnd":223,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/internals/interactive.py#L195-L223","documentation":"enable_interactive_mode() refuses (ValueError 'Cannot enable interactive mode') when the global graph G.global_scope is not empty, i.e. some tables/operators were already built. Interactive mode must be switched on before any pathway computation is defined; it is also experimental and emits a warning. If a controller already exists it is returned idempotently instead of raising.","triggerScenarios":"Calling pw.internals.enable_interactive_mode() (or the recompute()-style entry points that call it) after creating connectors, tables, or any pw.Table in the process; importing a module that defines a pipeline and then enabling interactive mode.","commonSituations":"Jupyter workflows where earlier cells already built tables; library imports that construct pathway pipelines at import time; second call in a fresh kernel after partial graph construction.","solutions":["Call pw.internals.enable_interactive_mode() as the first pathway statement in the notebook/session, before defining any connectors or tables","Restart the Python kernel / process to clear G.global_scope, then enable interactive mode first","Move pipeline-building imports/code after the enable_interactive_mode() call"],"exampleFix":"# before\nimport pathway as pw\nt = pw.debug.table_from_markdown('a\\n1')\npw.internals.enable_interactive_mode()  # ValueError\n\n# after\nimport pathway as pw\npw.internals.enable_interactive_mode()  # enable first\nt = pw.debug.table_from_markdown('a\\n1')","handlingStrategy":"validation","validationCode":"import pathway as pw\n\ndef ensure_interactive():\n    if not pw.internals.parse_graphs.G.global_scope.is_empty():\n        raise RuntimeError(\"restart kernel; interactive mode must be enabled before any pathway objects\")\n    return pw.internals.enable_interactive_mode()","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Make enable_interactive_mode() the first pathway call in the notebook kernel's lifetime","Keep pipeline definitions in functions you call after enabling interactive mode, not at import time"],"tags":["pathway","interactive-mode","notebook","api-misuse"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}