> ## Documentation Index
> Fetch the complete documentation index at: https://private-04b27de1.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# autogen.coding.jupyter.JupyterCodeExecutor

<h2 id="autogen.coding.jupyter.JupyterCodeExecutor" class="doc doc-heading">
  <code class="doc-symbol doc-symbol-heading doc-symbol-class" />

  <span class="doc doc-object-name doc-class-name">JupyterCodeExecutor</span>
</h2>

```python theme={null}
JupyterCodeExecutor(
    jupyter_server: JupyterConnectable | JupyterConnectionInfo,
    kernel_name: str = 'python3',
    timeout: int = 60,
    output_dir: Path | str = PosixPath('.')
)
```

(Experimental) A code executor class that executes code blocks and returns the result.<br />(Experimental) A code executor class that executes code statefully using
a Jupyter server supplied to this class.<br />Each execution is stateful and can access variables created from previous
executions in the same session.<br />

<b>Parameters:</b>

| Name             | Description                                                                                                                                                                                |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `jupyter_server` | **Type:** [JupyterConnectable](/docs/api-reference/autogen/coding/jupyter/JupyterConnectable) \| [JupyterConnectionInfo](/docs/api-reference/autogen/coding/jupyter/JupyterConnectionInfo) |
| `kernel_name`    | **Type:** str<br /><br />**Default:** 'python3'                                                                                                                                            |
| `timeout`        | **Type:** int<br /><br />**Default:** 60                                                                                                                                                   |
| `output_dir`     | **Type:** pathlib.Path \| str<br /><br />**Default:** PosixPath('.')                                                                                                                       |

### Instance Attributes

<code class="doc-symbol doc-symbol-heading doc-symbol-attribute" />

#### code\_extractor

<br />

(Experimental) Export a code extractor that can be used by an agent.

### Instance Methods

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### execute\_code\_blocks

```python theme={null}
execute_code_blocks(self, code_blocks: list[CodeBlock]) -> IPythonCodeResult
```

(Experimental) Execute a list of code blocks and return the result.<br />This method executes a list of code blocks as cells in the Jupyter kernel.<br />See: [https://jupyter-client.readthedocs.io/en/stable/messaging.html](https://jupyter-client.readthedocs.io/en/stable/messaging.html)
for the message protocol.<br />

<b>Parameters:</b>

| Name          | Description                                                                                                             |
| ------------- | ----------------------------------------------------------------------------------------------------------------------- |
| `code_blocks` | A list of code blocks to execute.<br /><br />**Type:** list\[[CodeBlock](/docs/api-reference/autogen/coding/CodeBlock)] |

<b>Returns:</b>

| Type                                  | Description                                          |
| ------------------------------------- | ---------------------------------------------------- |
| autogen.coding.base.IPythonCodeResult | IPythonCodeResult: The result of the code execution. |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### restart

```python theme={null}
restart(self) -> None
```

(Experimental) Restart a new session.

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### stop

```python theme={null}
stop(self) -> None
```

Stop the kernel.

<br />
