'Kernel process Exited - VSCode Interactive window for python

I've been using the Interactive window in VSCode to test my code and the kernel suddenly stopped working.

There are two available kernels: Python 3.9.9 64-bit (windows store), and Python 3.9.7 64-bit

The default being loaded each time I open the window is the former, which gives the 'Kernel process Exited' error, and the other one says it requires ipykernel installed, which is already installed.

Is there a way to fix the kernel issue or is there a better way to test my python code?

Do you have any recommendations for how to call functions from a python file in VSCode?



Solution 1:[1]

About kernel question, It basically means the program has finished running. If the code is not giving the answer you are expecting, you may try the following two ways, or even have to provide code.

1. Restart Kernel: enter image description here

2. Create virtual environment.

 python -m venv .venv

Selecting it as python interpreter and activating it in terminal, then select it in Jupyter and it will notice you install required ipykernel.

Reference: Create a virtual environment and Select and activate an environment

Then, call functions from a python file in VS Code. Treat it as a module, see the example that i call the func() from a.py in both b.py and jupyter notebook:

enter image description here

Solution 2:[2]

Installing the jupyter notebook and restarting the kernel worked for me.

pip install notebook

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Molly Wang-MSFT
Solution 2 sklal