Jupyter Qt console
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
- gotcha When installing via `pip`, Qt bindings (e.g., PyQt5, PySide2) are *not* automatically installed. These must be installed separately. Using `conda install qtconsole` typically handles this dependency automatically.
- breaking In version 4.3, the `ConsoleWidget.width` and `ConsoleWidget.height` traits were renamed to `console_width` and `console_height` respectively to avoid clashes with `QWidget` properties.
- gotcha When embedding `qtconsole` in a custom Qt application, user code executed in the kernel runs in a separate process from the frontend. This means you cannot directly access the `QtApplication` instance of the `QtConsole` itself from within the kernel's executed code.
- gotcha Users have reported issues with the `qtconsole` freezing and throwing `QTextCursor::setPosition: out of range` errors after calling `input()`, and crashes when using the 'auto' backend with Matplotlib.
- gotcha There are reports of `Segfault on import` when running `qtconsole` against Qt 6.7 on 64-bit Windows 11 with Python 3.12, indicating potential compatibility issues with newer Qt or Python versions.
Install
-
pip install qtconsole -
conda install qtconsole
Imports
- RichJupyterWidget
from qtconsole.rich_jupyter_widget import RichJupyterWidget
- QtInProcessKernelManager
from qtconsole.inprocess import QtInProcessKernelManager
Quickstart
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()