Luis
Luis

Reputation: 423

Failed to start the Kernel - Jupyter in VS Code

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

Upvotes: 32

Views: 115030

Answers (13)

Steven-MSFT
Steven-MSFT

Reputation: 8431

Could you try to reinstall the pyzmq module?

pip uninstall pyzmq
pip install pyzmq==19.0.2  

The version number may be different depending on the jupyter-client version.

Upvotes: 21

RajendraW
RajendraW

Reputation: 29

I had 3 python installations - Installed Pythons found by py Launcher for Windows
-3.10-64 *
-3.9-64
-3.7-64

Using v 3.9 I created virtual environment and tried to run jupyter notebook code and got same error

After digging into the issue for sometime, I found that I had done installation of Anaconda and python v 3.9 was installed in anaconda.
While creating virtual environment, I used non-conda commands for conda installed python version, that was causing the issue.
After removing VE and reinstalling with v3.10 with non-conda commands, I am able to work in VSCode with jupyter nb for the environment.

Upvotes: 0

auhre
auhre

Reputation: 1

Saw it has something to do with sockets, try upgrading tornado by this simple command pip install jupyter

Upvotes: 0

Alex Punnen
Alex Punnen

Reputation: 6244

Well after un-installation and installation of VSCode, conda and the like from my Linux PC, I too faced this and was wondering

Basically, I had to install Python again. Looks so obvious and I am not a newbie.. still

https://marketplace.visualstudio.com/items?itemName=ms-python.python

Cntrl+P

ext install ms-python.python

Upvotes: 0

This is somewhat related. I got an error regarding the pyzmq module needing to be reinstalled. In the end, I ended up having a file in my folder structure that was conflicting with an import (as in I had random.py which was conflicting with the import for the random import.)

I would just check to make sure that you have no files that could lead to such an issue.

Upvotes: 1

Douglas Adams
Douglas Adams

Reputation: 1

I tried a lot of things but the only thing that worked was switching to a pre-release version of jupyter in the extensions tab and reloading.

Upvotes: 0

Jonathan alis
Jonathan alis

Reputation: 61

I clicked in extensions, selected Jupyter, and there was a reload button behind it. It worked after I clocked it.

Upvotes: 0

Diyanko Bhowmik
Diyanko Bhowmik

Reputation: 41

I faced a similar problem for the last couple of days and tried almost all the solutions available including the following

  • Re-installing conda, python, jupyter, VS-code.
  • Updating pyzmq and many other suggested packages and dependencies.
  • Trying running on a local server (which worked but was not what I was looking for)

Finally what worked was simply switching the Jupyter extension in VS Code to the Pre-release version. Jupyter Extension

Upvotes: 4

Vinicius Raphael
Vinicius Raphael

Reputation: 381

Unfortunately I tried some options previously provided but none of them worked.

pip install pyzmq==19.0.2 
pip install jupyter

Only thing that worked was to go to the Jupyter extension in VS CODE and change from Release Version to Pre-Release version and reload the program.

enter image description here

Upvotes: 7

philipnye
philipnye

Reputation: 685

Building off the work of @Steven-MSFT and @Con O'Leary, try:

pip install --upgrade pyzmq

This upgrades the pyzmq package. As @Con O'Leary notes, recent versions of jupyter-client require more more recent versions of pyzmq.

Upvotes: 1

Con O'Leary
Con O'Leary

Reputation: 119

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 ¯\(ツ)

Upvotes: 6

SirIcarus
SirIcarus

Reputation: 371

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.

Upvotes: 26

Louis
Louis

Reputation: 46

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).

Upvotes: 0

Related Questions