Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jupyter Server: No Kernel Python: Not Started #1128

Closed
Tracked by #1122
bigrat911 opened this issue Jan 17, 2020 · 76 comments
Closed
Tracked by #1122

Jupyter Server: No Kernel Python: Not Started #1128

bigrat911 opened this issue Jan 17, 2020 · 76 comments
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster notebook-kernel Kernels issues (start/restart/switch/execution, install ipykernel)

Comments

@bigrat911
Copy link

Bug: Notebook Editor, Interactive Window, Editor cells

Steps to cause the bug to occur

  1. Open VS Code
  2. Cmd+Shift+P, Creat New Jupyter

Actual behavior

Jupyter Server: No Kernel
Python: Not Started
image
Error: [Errno 13] Permission denied: '/Users/XXXXX/Library/Jupyter/kernels/python37364bitbasecondac02285ab1a5b43e69345d43980645608'
Perhaps you want sudo or --user?

Expected behavior

Jupyter Server worked well

Your Jupyter and/or Python environment

Please provide as much info as you readily know

  • Jupyter server running: Local
  • Extension version: 2020.1.58038-xxx
  • VS Code version: 1.41.1
  • Setting python.jediEnabled: true
  • Python and/or Anaconda version: 3.7.3
  • OS: Mac
  • Virtual environment: conda

Developer Tools Console Output

Microsoft Data Science for VS Code Engineering Team: @rchiodo, @IanMatthewHuff, @DavidKutu, @DonJayamanne, @greazer

@rchiodo
Copy link
Contributor

rchiodo commented Jan 17, 2020

Thanks for the bug. Are you running VS code as the same user as yourself? Seems odd that we wouldn't be able to write to your users folder.

@bigrat911
Copy link
Author

Thanks for the bug. Are you running VS code as the same user as yourself? Seems odd that we wouldn't be able to write to your users folder.

Yes, looks strange. I am running it as the same user as myself, and I don't know how to use another user.
I wonder is "Jupyter Server: No Kernel Python: Not Started" normal??

@rchiodo
Copy link
Contributor

rchiodo commented Jan 21, 2020

It should have that status before you run any cells, but then it should register the kernel. It looks like it's not able to write to the user location on disk.

Does that place actually exist? Is this location writable by you?

/Users/XXXX/Library/Jupyter/Kernels

@lhl2617
Copy link

lhl2617 commented Jan 21, 2020

https://www.reddit.com/r/vscode/comments/eq2bfv/vs_code_jupyter_server_no_kernel_python_not/

For some reason this fixed the issue for me - hopefully it's helpful.

@rchiodo
Copy link
Contributor

rchiodo commented Jan 21, 2020

It's supposed to say no server/no kernel until you run. That's by design. That's not the issue @bigrat911 is seeing though. When @bigrat911 runs a cell, it still doesn't work because we can't write the kernel.json file to their user directory.

@microsoft microsoft deleted a comment from brando90 Jan 22, 2020
@microsoft microsoft deleted a comment from brando90 Jan 22, 2020
@microsoft microsoft deleted a comment from brando90 Jan 22, 2020
@brando90
Copy link

@rchiodo thanks for the help so far. I read through the whole issue but I am confused/unsure what "fix" you are referring to. Do you mind telling me what the instructions are or what you are referring to?

@weijiew
Copy link

weijiew commented Jan 23, 2020

I also encountered the same problem, the webpage could not be opened, how to solve this problem, thanks.

@rchiodo
Copy link
Contributor

rchiodo commented Jan 23, 2020

This issue is a problem with VS code writing to the /users/<user name>/library/jupyter/kernels folder. If you're having this issue it would show this problem in the console output (Help | Toggle Developer Tools, click on the console page).

There is another problem where if conda doesn't get activated, you can't run any jupyter code. There's multiple issues related to that:
https://github.com/microsoft/vscode-python/issues/9566 (which the fix is already in our insider's build)
https://github.com/microsoft/vscode-python/issues/8928 (which is currently being worked on).

@brando90 I believe your problem was entirely to do with conda not being setup right. I believe? @DonJayamanne helped you out in the comments for microsoft/vscode-python#9105

@weijew I'm not sure what your problem is. What webpage could not be opened?

@brando90
Copy link

@brando90 I believe your problem was entirely to do with conda not being setup right. I believe?

sort of. I used the same .bashrc and .zshrc files in pycharm and their jupyter feature worked fine. I shouldn't need to change my files for vs code to work...specially if my terminal works normal regardless of those files etc...that's my 2 cents.

But yes, for now we found a solution to it.

@weijiew
Copy link

weijiew commented Jan 25, 2020

Thanks for your answer, I solved the problem. Something went wrong with my conda activation

@janosh
Copy link
Contributor

janosh commented Jan 27, 2020

@rchiodo Even with the hints in this thread so far, I'm unable to resolve the issue. Still getting Jupyter Server: No Kernel, Python: Not Started. My console shows the following errors

Error Python Extension: 2020-01-27 13:24:05: Failed to serialize gatherRules for DATASCIENCE.SETTINGS [TypeError: Cannot convert object to primitive value at Array.join () at Array.toString () at /Users/janosh/.vscode/extensions/ms-python.python-2020.2.59126-dev/out/client/extension.js:1:12243 at Array.forEach () at Object.l [as sendTelemetryEvent] (/Users/janosh/.vscode/extensions/ms-python.python-2020.2.59126-dev/out/client/extension.js:1:12160) at y.sendSettingsTelemetry (/Users/janosh/.vscode/extensions/ms-python.python-2020.2.59126-dev/out/client/extension.js:75:708637) at y.r.value (/Users/janosh/.vscode/extensions/ms-python.python-2020.2.59126-dev/out/client/extension.js:1:92097) at Timeout._onTimeout (/Users/janosh/.vscode/extensions/ms-python.python-2020.2.59126-dev/out/client/extension.js:1:90616) at listOnTimeout (internal/timers.js:531:17) at processTimers (internal/timers.js:475:7)]

t.log @ console.ts:137
console.ts:137 [Extension Host] Error Python Extension: 2020-01-27 13:24:11: Failed to create File hash for interpreter /usr/local/Caskroom/miniconda/base/envs/old-env/bin/python [Error: ENOENT: no such file or directory, lstat '/usr/local/Caskroom/miniconda/base/envs/old-env/bin/python'] { errno: -2, code: 'ENOENT', syscall: 'lstat', path: '/usr/local/Caskroom/miniconda/base/envs/old-env/bin/python'}

The first is probably unrelated but the second seems to suggest that it's looking for a kernel in an old deleted conda environment. I looked in

/Users/janosh/Library/Jupyter/kernels/python361064bitoldenvconda79da1f2e6bbd4084ac835e29ddf1536d

and replaced all mentions of oldenv with newenv. Made no difference, the error remains. I checked the permissions: drwxr-xr-x. Nothing unusual AFAICT. At this point I wonder where the reference to the old env is even coming from.

@rchiodo
Copy link
Contributor

rchiodo commented Jan 27, 2020

@janosh what does jupyter kernelspec list show?

@janosh
Copy link
Contributor

janosh commented Jan 27, 2020

@rchiodo This is what I get

Available kernels:
python361064bitoldenvconda79da1f2e6bbd4084ac835e29ddf1536d /Users/janosh/Library/Jupyter/kernels/python361064bitoldenvconda79da1f2e6bbd4084ac835e29ddf1536d
python3 /usr/local/Caskroom/miniconda/base/envs/newenv/share/jupyter/kernels/python3

@rchiodo
Copy link
Contributor

rchiodo commented Jan 27, 2020

@janosh can you attach your console log? That should list out where we're finding the oldenv from.

@janosh
Copy link
Contributor

janosh commented Jan 27, 2020

@rchiodo Sure thing:

-1580142210149.log

@rchiodo
Copy link
Contributor

rchiodo commented Jan 27, 2020

@janosh that doesn't look like the entire log. Did you apply a filter? That looks like only the errors.

@janosh
Copy link
Contributor

janosh commented Jan 27, 2020

@rchiodo Ah sorry, I thought we only cared about the errors. Here's the full log.

-1580142893352.log

@rchiodo
Copy link
Contributor

rchiodo commented Jan 27, 2020

What does conda info --envs report? Looks like we're finding the oldenv during our lookup. Do you have this environment set as the current python?

@janosh
Copy link
Contributor

janosh commented Jan 27, 2020

@rchiodo conda info --envs returns

# conda environments:
#
base                  *  /usr/local/Caskroom/miniconda/base
newenv                   /usr/local/Caskroom/miniconda/base/envs/newenv

The env shown in the status bar is newenv.

@rchiodo
Copy link
Contributor

rchiodo commented Jan 27, 2020

Hmm. @DonJayamanne do we cache the environments somewhere? This is on a linux machine so it's not in the registry. Where would the 'oldenv' environment come from if not from conda info --envs?

@janosh
Copy link
Contributor

janosh commented Jan 28, 2020

In case it helps to pinpoint the issue, if I try to execute a cell in a blank Jupyter notebook (rather than in the interactive window), I get the error:

Error: Jupyter cannot be started. Error attempting to locate jupyter:
at A.startServerImpl (/Users/janosh/.vscode/extensions/ms-python.python-2020.2.59126-dev/out/client/extension.js:1:770704)
at async A.ensureServerActive (/Users/janosh/.vscode/extensions/ms-python.python-2020.2.59126-dev/out/client/extension.js:1:770251)
at async A.clearResult (/Users/janosh/.vscode/extensions/ms-python.python-2020.2.59126-dev/out/client/extension.js:1:766749)
at async A.reexecuteCell (/Users/janosh/.vscode/extensions/ms-python.python-2020.2.59126-dev/out/client/extension.js:75:889464)

no-jupyter

@DonJayamanne
Copy link
Contributor

we cache the environments

Yes it's cached in the memento.
@janosh

  • Please could you open the Jupyter output panel and let us know what's in there?
  • Open the command Select Jupyter Interpreter.. and let us know what currently selected, should be displayed in the picker input as a placeholder. Please select an interpreter that you'd like to use for Jupyter from this list.
  • I suspect there are some more errors logged in the console window, possibly with more details, please could you paste your entire log.

@janosh
Copy link
Contributor

janosh commented Jan 28, 2020

Open the command Select Jupyter Interpreter.. and let us know what currently selected, should be displayed in the picker input as a placeholder. Please select an interpreter that you'd like to use for Jupyter from this list.

@DonJayamanne Cool! I didn't know about this command. I just selected newenv in the resulting dropdown and all is back to working! Thanks a lot! 👍

Are you still interested in the Jupyter output? I'm afraid I can't reproduce the issue now since I can't reselect the old deleted env that was apparently cached somewhere.

I suspect there are some more errors logged in the console window, possibly with more details, please could you paste your entire log.

I did upload the full logs above.

@rchiodo
Copy link
Contributor

rchiodo commented Jan 28, 2020

@DonJayamanne maybe we have a bug in our 'working jupyter' cache? That if it doesn't work, we don't search elsewhere?

@rchiodo
Copy link
Contributor

rchiodo commented Jan 28, 2020

Oh and thanks @janosh

@janosh
Copy link
Contributor

janosh commented Jan 28, 2020

@rchiodo No problem and thanks for your help!

@NicoZing
Copy link

NicoZing commented Feb 3, 2020

Hi @bigrat911 in my case I had similar issue with Jupyter server and it worked well by doing:
1º Start new .ipynd notebook in Vs
2º Ctrl+shift + P >> Python: Specify local or remote server for connections
3º Default
4º Run some code.

Basically I changed the server and worked well.

Hope this will be helpfull.

@jrounds
Copy link

jrounds commented Jun 5, 2020

image
image

Pretty sure this is the right log file. Only log file I ever made that I cut into another file to edit out identifiers.

If we add up what you just said and what I claimed earlier that the log said it was not using the right remote port they work out to this:
Some how it is launching with stale info not represented in the UI.

Is there a way to clean anything that might be cached anywhere?

Incidently I had another data point that points to stale info. When I noticed the remote log was ignoring the port I put into the vscode UI remote URL, I went and set up a jupyter server at the port vscode-python was actually logging as using. That started logging events on the jupyter side but the jupyter server said vscode-python was using bad URLs.

@rchiodo
Copy link
Contributor

rchiodo commented Jun 5, 2020

Hmm. Well you might start with updating VS code. It's a bit out of date (should be on 1.45.1 right now).

Then uninstall and reinstall the python extension (reloading VS code in between each). Not sure how the setting would be coming out wrong. You can check the settings.json too (the UI should just be reading the settings.json, which is what we read to get the setting).

@jrounds
Copy link

jrounds commented Jun 5, 2020

The newer version is my actual install in applications. I did the uninstall/restart of vscode-python. This what is in my User settings json looks like

{
    "telemetry.enableTelemetry": false,
    "workbench.colorTheme": "Default Light+",
    "python.linting.pylintCategorySeverity.convention": "Warning",
    "python.linting.pylintCategorySeverity.error": "Error",
    "python.linting.mypyCategorySeverity.note": "Warning",
    "python.linting.pycodestyleCategorySeverity.W": "Error",

    "workbench.colorCustomizations": {
        "activityBar.background": "#00AA00",
        "editorError.foreground": "#ff0000",
        "editorError.border": "#ff0000",
        "editorWarning.foreground": "#e49638"
    },
    "python.linting.pylintCategorySeverity.refactor": "Error",
    "files.autoSaveDelay": 100,
    "files.autoSave": "afterDelay",
    "editor.tabCompletion": "on",
    "editor.detectIndentation": false,
    "editor.formatOnPaste": false,
    "terminal.integrated.scrollback": 10000,
    "editor.useTabStops": false,
    "terminal.external.osxExec": "/bin/bash",
    "terminal.integrated.shell.osx": "/bin/bash",
    "terminal.integrated.shellArgs.osx": ["-l"],
    "terminal.explorerKind": "integrated",
    "workbench.iconTheme": "material-icon-theme",
    "python.linting.pylintUseMinimalCheckers": false,
    "python.analysis.diagnosticPublishDelay": 10,
    "python.linting.pylintCategorySeverity.warning": "Error",
    "python.linting.pylintArgs": [
        "--disable=using-constant-test,logging-not-lazy,invalid-name,trailing-whitespace,mixed-indentation,bad-whitespace,line-too-long,redefined-outer-name"
    ],
    "editor.renderWhitespace": "all",
    "editor.trimAutoWhitespace": false,
    "python.dataScience.sendSelectionToInteractiveWindow": true,
    "terminal.integrated.env.osx": {
        "PATH": ""
},
"terminal.integrated.inheritEnv": false,
"window.zoomLevel": -1,
"workbench.tree.indent": 30,
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"python.jediEnabled": false,
"terminal.integrated.rendererType": "experimentalWebgl",
"r.bracketedPaste": false,
"python.condaPath":"/Users/USERNAME/anaconda3/condabin/conda"
}

It occurs to me I don't know how that json file stays up to date as new versions of things roll in. That particular one user settings.json is over a year old now.

@jrounds
Copy link

jrounds commented Jun 5, 2020

Fixed it.

Your comments got me thinking about settings so I started sniffing around .vscode folders.

Inside my project directory was a settings.json as:

{
    "python.pythonPath": "/Users/USERNAME/anaconda3/envs/m2/bin/python",
    "python.dataScience.jupyterServerURI": "http://localhost:8889/?token=7f88c4411629ad42dc415750c8546ef525852090b2f6050b"
}

I deleted the python.dataScience.jupyterServerURI line, restarted and vscode-python took over from there and "local" works again.

@johnjim0816
Copy link

johnjim0816 commented Jun 10, 2020

I have seen all possible solutions but not work, finally I just upgrade jupyter,notebook,and jupyterlab,like pip3 install -U jupyterlab, and I can choose the kernel in VScode!
image

@giladpn
Copy link

giladpn commented Jul 2, 2020

Same issue, but with a solution. I am on

  • Windows 10
  • VS Code 1.46.1 (latest and greatest, as of today)
  • Python 3.7.6

The proximate cause of the problem was an attempt to install a new library (actually pysyft). As far as I can see, this pysyft installation messed up some of the Jupyter dependencies, specificaly messing up the version of tornado (pysyft requires one version, Jupyter requires another, etc).

Here is what solved it for me:

  1. First completely uninstalled Jupyter from the virtual environment:
py -m uninstall jupyter
  1. Then closed vscode, reopened it, and...
  2. ... tried to start a "data science" cell in one of my projects.
  3. vscode told me I do not have Jupyter (which was true) and offered to install it.
  4. Said "yes" --> vscode installed Jupyter as per the version vscode needs.

After that everything ran as supposed to (except pysyft, which no longer has the version that it needs).

I hope this helps others. It seems the basic issue is - as you install new things - version dependencies may be different for different projects.

Advice to the vscode-python team:
Try installing e.g. pysyft and see its dependencies on tornado and jupyter;
verify that with these specific versions - the vscode "data science" functionality does work well
(or at least document the requirement mismatch)

Cheers!

@AlanIsaacV
Copy link

Making sure that VS Code setting

"python.condaPath": "C:\\Program Files\\miniconda3\\Scripts\\conda.exe"

is pointing to the correct directory solved it for me

I removed the conda path option and that worked

@DonJayamanne DonJayamanne transferred this issue from microsoft/vscode-python Nov 13, 2020
@DonJayamanne DonJayamanne added bug Issue identified by VS Code Team member as probable bug temp-address-multiple-venv-conda labels Nov 13, 2020
@Natemen96
Copy link

Fixed it.

Your comments got me thinking about settings so I started sniffing around .vscode folders.

Inside my project directory was a settings.json as:

{
    "python.pythonPath": "/Users/USERNAME/anaconda3/envs/m2/bin/python",
    "python.dataScience.jupyterServerURI": "http://localhost:8889/?token=7f88c4411629ad42dc415750c8546ef525852090b2f6050b"
}

I deleted the python.dataScience.jupyterServerURI line, restarted and vscode-python took over from there and "local" works again.

similar to @jrounds solutions, commenting out my python.condaPath in the setting.json, restarted, and it fixed it for me.

However, for me, the issue came when I started to used the new Settings Sync extension which I believe in the process mess up some file paths in the settings between devices. It's a useful extension when commonly switching between devices but it doesn't come without pain.

@greazer greazer added this to the July 2021 Release milestone Jun 8, 2021
@greazer greazer modified the milestones: July 2021, August 2021 Jul 30, 2021
@greazer greazer added the notebook-kernel Kernels issues (start/restart/switch/execution, install ipykernel) label Aug 2, 2021
@greazer greazer modified the milestones: August 2021, old August 2021 Aug 9, 2021
@DonJayamanne
Copy link
Contributor

Is anyone still running into these issues in the latest version of VS Code & Jupyter extension?

@DonJayamanne DonJayamanne added info-needed Issue requires more information from poster and removed issue_grooming_don labels Oct 18, 2021
@janosh
Copy link
Contributor

janosh commented Oct 18, 2021

@DonJayamanne Nope.

@DonJayamanne
Copy link
Contributor

@janosh thanks for getting back, sorry this didn't get much attention, we've been regularly working on kernel related issues and I'd like to ensure we have a great handle on all of those issues and I'm trying to clean them up. You can see that here #7901

I'm going to close this for now, thanks again

@janosh
Copy link
Contributor

janosh commented Oct 19, 2021

sorry this didn't get much attention

No complaints from me. Everything Python-related in VS Code been running very smoothly for a while now. Thanks for all your work! 👍

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster notebook-kernel Kernels issues (start/restart/switch/execution, install ipykernel)
Projects
None yet
Development

No branches or pull requests