25

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

Luis
  • 353
  • 1
  • 3
  • 6

9 Answers9

20

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.

SirIcarus
  • 301
  • 2
  • 4
17

Could you try to reinstall the pyzmq module?

pip uninstall pyzmq
pip install pyzmq==19.0.2
Steven-MSFT
  • 7,438
  • 1
  • 5
  • 13
6

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

Con O'Leary
  • 99
  • 1
  • 10
6

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

4

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

0

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

Louis
  • 46
  • 2
0

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.

philipnye
  • 352
  • 1
  • 3
  • 16
0

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

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 22 '23 at 13:05
0

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.