Interacting with the Kernel for Python Programming
The kernel is the server that enables Python programmers to run cells within Notebook. You typically see the kernel commands in a separate command or terminal window.
Each entry shows the time the kernel executed the task, which application the command executed, the task it performed, and any resources affected. In most cases, you don’t need to do anything with this window, but viewing it can be helpful when you run into problems because you often see error messages that can help you resolve an issue.
You control the kernel in a number of ways. For example, saving a file issues a command to the kernel, which carries the task out for you. However, you also find some kernel-specific commands on the Kernel menu, which are described in the following list:
- Interrupt: Causes the kernel to stop performing the current task without actually shutting the kernel down. You can use this option when you want to do something like stop processing a large dataset.
- Restart: Stops the kernel and starts it again. This option causes you to lose all the variable data. However, in some cases, this is precisely what you need to do when the environment has become dirty with old data.
- Restart & Clear Output: Stops the kernel, starts it again, and clears all the existing cell outputs.
- Restart & Run All: Stops the kernel, starts it again, and then runs every cell starting from the top cell and ending with the last cell. When Notebook reaches the bottom, it selects the last cell but doesn’t insert a new one.
- Reconnect: Recreates the connection to the kernel. In some cases, environmental or other issues could cause the application to lose its connection, so you use this option to reestablish the connection without loss of variable data.
- Shutdown: Shuts the kernel down. You may perform this step in preparation for using a different kernel.
- Change Kernel: Selects a different kernel from the list of kernels you have installed. For example, you may want to test an application using various Python versions to ensure that it runs on all of them.