Jupyter Qt console

5.7.2 · active · verified Thu Apr 09

The Qtconsole is a rich Qt-based application providing an interactive console for Jupyter kernels. It largely feels like a terminal but offers graphical user interface enhancements such as inline figures, proper multiline editing with syntax highlighting, and graphical calltips. It is currently at version 5.7.2, maintained by the Spyder development team, and is part of the broader Project Jupyter ecosystem, with a consistent release cadence for features and bug fixes.

Warnings

Install

Imports

Quickstart

The simplest way to start the Qt console is by running `jupyter qtconsole` from your terminal. For embedding it into a custom Qt application, you can use `RichJupyterWidget` to host a Jupyter kernel in-process. This example demonstrates launching an in-process kernel and executing commands.

import sys
from qtconsole.rich_jupyter_widget import RichJupyterWidget
from qtconsole.inprocess import QtInProcessKernelManager
from PyQt5.QtWidgets import QApplication

def main():
    app = QApplication([])
    
    # Create a kernel manager and start a kernel
    kernel_manager = QtInProcessKernelManager()
    kernel_manager.start_kernel(show_banner=False)
    kernel_client = kernel_manager.client()
    kernel_client.start_channels()

    # Create the Qt console widget
    console = RichJupyterWidget()
    console.kernel_manager = kernel_manager
    console.kernel_client = kernel_client
    
    # Execute some code programmatically
    console.execute('print("Hello from embedded QtConsole!")')
    console.execute('import matplotlib.pyplot as plt')
    console.execute('plt.plot([1,2,3], [4,5,6])')
    console.execute('plt.show()')

    console.show()
    sys.exit(app.exec_())

if __name__ == '__main__':
    # To run this example, ensure you have:
    # pip install qtconsole ipykernel PyQt5
    main()

view raw JSON →