Set the Kernel Programmatically in a Jupyter Lab Notebook - jupyter-notebook

Can the kernel of Jupyter Lab be changed (set) programmatically inside a Jupyter lab notebook cell?
If so, how?
The alternative way is to use the Graphical User Interface of the Jupyter lab to change the lab from Kernel menu.

Related

Unable to set the kernel ("Not specified") for a jupyter notebook in Pycharm

As seen in the screenshot the kernel is "Not specified" and can not set since the dropdown is disabled. Can this be remedied?
The Project interpreter is python3 and otherwise for other file types the project works fine
I've run into the same issue of PyCharm not allowing me to select a Jupyter kernel other than the one that is saved to the notebook (the drop-down menu is either grayed-out as in your picture, or disappears altogether). This condition appears to occur when the kernel that was active when the notebook was saved is not available in the current environment. The only workaround I've found for this situation is:
Start a Jupyter notebook server using the same Python environment as you are using in PyCharm
From the Jupyter server web page, open the notebook
From the Kernel menu, select Change kernel, and then select the desired kernel
Save the notebook, then close/halt it
Re-open the notebook in PyCharm. It should then be able to execute with the kernel that was chosen in Step 3 above.

How to get Jupyter Lab to start fresh with no open kernels?

I've been using Jupyter Lab and everytime I open it, it has all of my notebooks from previous session open in Tabs and as open Kernels. I want to open my Jupyter with a fresh window that doesn't have anything I was working on previously.
How can I either modify my profile or Jupyter lab command to not include any previous Tabs or open Kernels?

Linking VS Code interactive window to running Jupyter notebook

Let's say that you have two windows open in VS Code, one is a Jupyter notebook, and the other is the Python interactive window. Both are running the same kernel. Is there a way to link these two windows, so when cells are run in the notebook, the interactive window will know about the resulting variables?
I'm aware that VS Code has a Python code format that can be linked to the interactive window, and that Jupyter notebooks can be converted into this format. Is it possible to directly link a Jupyter notebook to the interactive window without first doing this conversion?
With JupyterLab the is accomplished with the New Console for Notebook command.

Run A Specific Jupyter Notebook On Start

I would like to setup a system such that it not only runs jupyter notebook on start, but it also starts executing a specific notebook on that jupyter server (running all cells in sequence).
Is this possible? I specifically want to be able to access the notebook web interface and inspect/stop/etc the running notebook at any point.
I know nbconvert can execute a notebook, but it seems to run independently of any existing jupyter servers?
Maybe there is some API I can access so that I can write a shell script to run jupyter notebook and then use the API to open and run a notebook?

Can I start a Jupyter notebook using a Spyder kernel?

I have been able to start a remote ipython console using 'python -m spyder_kernels.console' and connect to it using Spyder on my local machine. However, this just gives me a console. I want to get a notebook running remotely and connect to it using Spyder. I understand the Spyder kernel is different and has several modifications. My question is, can I start a remote Jupyter notebook, using a Spyder kernel, and then connect to this notebook from inside my local Spyder? I have the Spyder notebook plugin installed. The idea is that since the notebook is started using a Spyder kernel, Spyder should be able to interact with it and the Variable Explorer should work.
PS: I know it should be possible to start a Jupyter notebook with the Spyder kernel, because that's exactly what the notebook plugin for Spyder does inside of Spyder. I just want the ability to start this notebook remotely and then connect to it.

Resources