How to use the qtconsole.manager.QtKernelManager function in qtconsole

To help you get started, we’ve selected a few qtconsole examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Spine-project / Spine-Toolbox / spinetoolbox / widgets / python_repl_widget.py View on Github external
def start_python_kernel(self):
        """Starts kernel manager and client and attaches
        the client to the Python Console."""
        self._kernel_starting = True
        km = QtKernelManager(kernel_name=self.kernel_name)
        try:
            blackhole = open(os.devnull, 'w')
            km.start_kernel(stdout=blackhole, stderr=blackhole)
            kc = km.client()
            kc.start_channels()
            self.kernel_manager = km
            self.kernel_client = kc
            self.connect_signals()
            return True
        except FileNotFoundError:
            self._toolbox.msg_error.emit("\tCouldn't find the Python executable specified by the Jupyter kernel")
            self._kernel_starting = False
            return False
        except NoSuchKernel:  # kernelspecs for the selected kernel_name not available
            self._toolbox.msg_error.emit(
                "\tCouldn't find the specified IPython kernel specs [{0}]".format(self.kernel_name)
github mu-editor / mu / mu / modes / python3.py View on Github external
"{}".format(self.envars)
        )
        for k, v in self.envars.items():
            os.environ[k] = v
        # Ensure the expected paths are in PYTHONPATH of the subprocess so the
        # kernel and Mu-installed third party applications can be found.
        if "PYTHONPATH" not in os.environ:
            paths = sys.path + [MODULE_DIR]
            os.environ["PYTHONPATH"] = os.pathsep.join(paths)
        if MODULE_DIR not in os.environ["PYTHONPATH"]:
            # This is needed on Windows to ensure user installed third party
            # packages are available in the REPL.
            new_path = os.pathsep.join([os.environ["PYTHONPATH"], MODULE_DIR])
            os.environ["PYTHONPATH"] = new_path
        logger.info("REPL PYTHONPATH: {}".format(os.environ["PYTHONPATH"]))
        self.repl_kernel_manager = QtKernelManager()
        self.repl_kernel_manager.start_kernel()
        self.repl_kernel_client = self.repl_kernel_manager.client()
        self.kernel_started.emit(
            self.repl_kernel_manager, self.repl_kernel_client
        )
github neuropy / neuropy / neuropy / main.py View on Github external
def main():
    """Start kernel manager and client, create window, run app event loop,
    auto execute some code in user namespace. A minimalist example is shown in
    qt_ip_test.py.

    NOTE: Make sure that the Qt v2 API is being used by IPython by running `export
    QT_API=pyqt` at the command line before running neuropy, or by adding it to `.bashrc`"""
    app = guisupport.get_app_qt4()

    if INPROCESS:
        from qtconsole.inprocess import QtInProcessKernelManager
        km = QtInProcessKernelManager()
    else:
        from qtconsole.manager import QtKernelManager
        km = QtKernelManager()
    km.start_kernel()
    km.kernel.gui = 'qt4'
    kc = km.client()
    kc.start_channels()

    nw = NeuropyWindow()
    ipw = nw.ipw
    config_ipw(ipw)
    ipw.kernel_manager = km
    ipw.kernel_client = kc
    ipw.exit_requested.connect(nw.stop)
    nw.show()

    # execute some code through the frontend (once the event loop is running).
    # The output appears in the IPythonWidget (ipw).
    do_later(ipw.execute, 'run -i %s' % 'startup.py', hidden=True)
github pcdshub / typhon / typhos / tools / console.py View on Github external
def _make_jupyter_widget_with_kernel(kernel_name):
    """
    Start a kernel, connect to it, and create a RichJupyterWidget to use it.

    Parameters
    ----------
    kernel_name : str
        Kernel name to use.
    """
    kernel_manager = QtKernelManager(kernel_name=kernel_name)
    kernel_manager.start_kernel()

    kernel_client = kernel_manager.client()
    kernel_client.start_channels()

    jupyter_widget = RichJupyterWidget()
    jupyter_widget.kernel_manager = kernel_manager
    jupyter_widget.kernel_client = kernel_client
    return jupyter_widget
github flika-org / flika / flika / app / terminal.py View on Github external
def _init_kernel_manager(self):
        connection_file = find_connection_file(self.app.connection_file)
        manager = QtKernelManager(connection_file=connection_file)
        manager.load_connection_file()
        manager.start_channels()
        atexit.register(manager.cleanup_connection_file)
        self.kernel_manager = manager
github flika-org / flika / flika / app / terminal.py View on Github external
def default_manager(kernel):
    """ Return a configured QtKernelManager

    Parameters:
         kernel: An IPKernelApp instance
    """
    connection_file = find_connection_file(kernel.connection_file)
    manager = QtKernelManager(connection_file=connection_file)
    manager.load_connection_file()
    manager.start_channels()
    atexit.register(manager.cleanup_connection_file)
    return manager
github jupyter / qtconsole / examples / embed_qtconsole.py View on Github external
def make_jupyter_widget_with_kernel():
    """Start a kernel, connect to it, and create a RichJupyterWidget to use it
    """
    kernel_manager = QtKernelManager(kernel_name=USE_KERNEL)
    kernel_manager.start_kernel()

    kernel_client = kernel_manager.client()
    kernel_client.start_channels()

    jupyter_widget = RichJupyterWidget()
    jupyter_widget.kernel_manager = kernel_manager
    jupyter_widget.kernel_client = kernel_client
    return jupyter_widget