Failed to start the Kernel - Jupyter in VS Code

Viewed 14656

I am trying to use a Jupyter notebook for some Pandas in VS Code. I set up a virtual environment venv where I installed Pandas and jupyter. I always did it like this and it worked fine. But suddenly it does not work anymore. Code with error message

4 Answers

Could you try to reinstall the pyzmq module?

pip uninstall pyzmq
pip install pyzmq==19.0.2

I got the same error message because the jupyter package was missing in my selected environment.

pip install jupyter

resolved the problem for me.

From the official VS Code documentation:

To work with Python in Jupyter Notebooks, you must activate an Anaconda environment in VS Code, or another Python environment in which you've installed the Jupyter package.

Update to Steven-MSFT's solution:

pip uninstall pyzmq        #Steven-MSFT's solution
pip install pyzmq==19.0.2

pip install pyzmq          #Update

Explanation:

Installing 19.0.2 (after uninstalling) produced an error ..

jupyter-client 7.3.4 requires pyzmq>=23.0, but you have pyzmq 19.0.2 which is incompatible.

.. updating pyzmq to the latest version (23.2.0 at time of writing) by running pip install pyzmq resolved this error. I was originally on the latest version, so i'm not sure why this procedure of reverting and then reupgrading works ¯\(ツ)

A workaround would be to run the kernel in a separate terminal (using the jupyter notebook command), and to connect to that kernel from VS Code (Click on "Jupyter Server: local" and choose the kernel running on localhost from the list).

Related