vscode-python: Error command 'python.viewOutput' already exists: Jupyter notebook does not connect to kernel
It’s that time again: What time is it? The time when VS Code’s Jupyter extension randomly fails on the user! Hooray! Everyone’s favorite time!!!
Running VS Code locally connecting to our work server over SSH using the VS Code - Remote SSH extension. Was working fine until a few hours ago.
Jupyter extension v2022.5.1001601848 Python extension v2022.8.1
Connecting to kernel: my_conda_env_py_38 (Python 3.8.13): Activating Python Environment ‘Python 3.8.13 (‘my_conda_env_py_38’)’
Version: 1.68.1 (Universal) Commit: 30d9c6cd9483b2cc586687151bcbcd635f373630 Date: 2022-06-14T12:52:13.188Z Electron: 17.4.7 Chromium: 98.0.4758.141 Node.js: 16.13.0 V8: 9.8.177.13-electron.0 OS: Darwin x64 21.5.0
Steps to repro:
- Open a Jupyter notebook.
- Select kernel from upper right dropdown menu.
- Execute first cell of notebook with Shift+Enter.
Nothing happens:
Connecting to kernel: my_conda_env_py_38 (Python 3.8.13): Activating Python Environment ‘Python 3.8.13 (‘my_conda_env_py_38’)’ (Source: Jupyter (Extension)
Yes, I’m using the latest version of VS Code. Yes, I’m using the latest version of the Jupyter extension. Yes, I’m using the latest version of the Python extension. No, I didn’t update or change anything: one moment I’m executing cells in my notebook. Suddenly the notebook stops responding, and the “Select Kernel” appears in upper right of the notebook. Dunno why.
Try executing a cell with a simple print statement and all I see is “Go To Running Cell” spinning clockwise indefinitely while in the lower right, Connecting to kernel: my_conda_env_py_38 (Python 3.8.13): Activating Python Environment 'Python 3.8.13 ('my_conda_env_py_38')' (Source: Jupyter (Extension)
Several hours spent uninstalling Jupyter extension, uninstalling Python extension, reloading VS Code, reinstalling Jupyter extension, reinstalling Python extension, trying once again to run Jupyter notebook, getting the same error, trying to run the aforementioned steps in some other permutation. Cursing silently. Cursing aloud. Contemplating throwing laptop out of window.
I just want a stable IDE that is reliable, dependable, and doesn’t crash when using a notebook. That’s it.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 28 (2 by maintainers)
Similar issue repro with a local Linux installation – using miniconda 4.12.0 Checking the logs appears to say that the conda environment could not be activated by vscode
however, activating the conda environment works fine when done manually from the bash terminal. It just seems as if the extension’s exec environment isn’t making use of the init script installed inside
.bashrc
.Note that on a local installation, this produces a misleading error message on the GUI stating that jupyter and notebook need to be installed (even though they are already installed)
@loodvn Your issue seems different, can you create a new one with these details?
If you have deleted the other python extensions from both the local and ssh-remote installation of vscode, does the log still say
command 'python.viewOutput' already exists
?for now, a workaround is to open a terminal and manually activate the conda environment and run
jupyter notebook --no-browser
, then connect to the jupyter server as a remote jupyter server from vscode using the link generated by the jupyter CLI. If using ssh, port tunneling may be necessary.