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

Error attempting to locate Jupyter: Running cells with (...) requires jupyter package. #10856

Closed
michaelweinold opened this issue Jul 19, 2022 · 13 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug triage-needed Issue needs to be triaged

Comments

@michaelweinold
Copy link

Environment data

  • VS Code version: 1.69.2
  • Jupyter Extension version (available under the Extensions sidebar): v2022.6.1201981810
  • Python Extension version (available under the Extensions sidebar): v2022.10.1
  • OS (Windows | Mac | Linux distro) and version: macOS Monterey (12.4 (21F79))
  • Python and/or Anaconda version: Python 3.10.5 / conda 4.13.0
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): conda
  • Jupyter server running: Local

Expected behaviour

Jupyter installation in conda environment is recognized by vscode-jupyter.

Actual behaviour

VS Code does not recognize correctly installed Jupyter packages in conda environments. Jupyter Notebooks in the browser can be launched successfully from the activated environment. When attempting to run a notebook in VS Code, an error is thrown:

Screenshot 2022-07-19 at 12 16 28

info 12:44:44.504: Starting Jupyter Session id = 'startUsingPythonInterpreter:.jvsc74a57bd0ec1689aadfb31809087390f003aaaf48945ecfc3bbda01b3082716ecd7919b65./opt/miniconda3/envs/menv/python./opt/miniconda3/envs/menv/python.-m#ipykernel_launcher' (Python Path: /opt/miniconda3/envs/menv, EnvType: Conda, EnvName: 'menv', Version: 3.10.5) for '/Users/myuser/Downloads/Untitled.ipynb' (disableUI=true)
info 12:44:44.504: Checking for server existence.
info 12:44:44.504: Checking for server usability.
info 12:44:44.506: Server not usable (should ask for install now)
info 12:44:44.509: Process Execution: > /opt/miniconda3/envs/menv/bin/python -c "import jupyter"
> /opt/miniconda3/envs/menv/bin/python -c "import jupyter"
info 12:44:44.510: Process Execution: > /opt/miniconda3/envs/menv/bin/python -c "import notebook"
> /opt/miniconda3/envs/menv/bin/python -c "import notebook"
warn 12:44:44.610: Error occurred while trying to start the kernel, options.disableUI=true [i [Error]: Jupyter cannot be started. Error attempting to locate Jupyter: Running cells with 'Python 3.10.5 ('menv')' requires jupyter package.
	at S.startServer (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:98875)
	at processTicksAndRejections (node:internal/process/task_queues:96:5)
	at async S.createServer (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:97995)
	at async l.connect (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:75175)
	at async g.create (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:95736)
	at async p.createJupyterSession (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:160545)
	at async p.start (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:154488)
	at async Function.wrapKernelMethodImpl (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:336119)] {
  category: 'jupyterinstall'
}

Any attempt to proceed by clicking "install" ends with:

info 12:59:11.118: 
# All requested packages already installed.

Steps to reproduce:

  1. install miniconda (M1)
  2. create a new virtual environment (python 3.9) and install jupyter
  3. install VS Code (M1)
  4. install the Jupyter extension
  5. select the conda environment as kernel

Logs

Output for Jupyter in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Jupyter)

info 13:13:3.698: Execute Cell 1 /Users/myuser/Downloads/Untitled1.ipynb
info 13:13:3.699: Starting Jupyter Session id = 'startUsingPythonInterpreter:.jvsc74a57bd0ec1689aadfb31809087390f003aaaf48945ecfc3bbda01b3082716ecd7919b65./opt/miniconda3/envs/menv/python./opt/miniconda3/envs/menv/python.-m#ipykernel_launcher' (Python Path: /opt/miniconda3/envs/menv, EnvType: Conda, EnvName: 'menv', Version: 3.10.5) for '/Users/myuser/Downloads/Untitled1.ipynb' (disableUI=false)
info 13:13:3.699: Checking for server existence.
info 13:13:3.700: Checking for server usability.
info 13:13:3.700: Server not usable (should ask for install now)
info 13:13:3.703: Process Execution: > /opt/miniconda3/envs/menv/bin/python -c "import jupyter"
> /opt/miniconda3/envs/menv/bin/python -c "import jupyter"
info 13:13:3.704: Process Execution: > /opt/miniconda3/envs/menv/bin/python -c "import notebook"
> /opt/miniconda3/envs/menv/bin/python -c "import notebook"
warn 13:13:3.800: Error occurred while trying to start the kernel, options.disableUI=false [i [Error]: Jupyter cannot be started. Error attempting to locate Jupyter: Running cells with 'Python 3.10.5 ('menv')' requires jupyter package.
	at S.startServer (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:98875)
	at processTicksAndRejections (node:internal/process/task_queues:96:5)
	at async S.createServer (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:97995)
	at async l.connect (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:75175)
	at async g.create (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:95736)
	at async p.createJupyterSession (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:160545)
	at async p.start (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:154488)
	at async Function.wrapKernelMethodImpl (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:336119)] {
  category: 'jupyterinstall'
}
warn 13:13:3.800: Kernel Error, context = start [i [Error]: Jupyter cannot be started. Error attempting to locate Jupyter: Running cells with 'Python 3.10.5 ('menv')' requires jupyter package.
	at S.startServer (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:98875)
	at processTicksAndRejections (node:internal/process/task_queues:96:5)
	at async S.createServer (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:97995)
	at async l.connect (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:75175)
	at async g.create (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:95736)
	at async p.createJupyterSession (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:160545)
	at async p.start (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:154488)
	at async Function.wrapKernelMethodImpl (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:336119)] {
  category: 'jupyterinstall'
}
info 13:13:3.803: Process Execution: > /opt/miniconda3/envs/menv/bin/python -c "import jupyter"
> /opt/miniconda3/envs/menv/bin/python -c "import jupyter"
info 13:13:3.804: Process Execution: > /opt/miniconda3/envs/menv/bin/python -c "import notebook"
> /opt/miniconda3/envs/menv/bin/python -c "import notebook"
info 13:13:5.815: Process Execution: > /opt/miniconda3/condabin/conda install -c conda-forge --name menv jupyter -y
> /opt/miniconda3/condabin/conda install -c conda-forge --name menv jupyter -y
info 13:13:6.313: Collecting package metadata (current_repodata.json): ...working... 
info 13:13:7.200: done

info 13:13:7.200: Solving environment: ...working... 
info 13:13:8.65: done

info 13:13:8.253: 
# All requested packages already installed.


info 13:13:8.457: Process Execution: > /opt/miniconda3/envs/menv/bin/python -c "import jupyter"
> /opt/miniconda3/envs/menv/bin/python -c "import jupyter"
info 13:13:8.469: Dispose Kernel '/Users/myuser/Downloads/Untitled1.ipynb' associated with '/Users/myuser/Downloads/Untitled1.ipynb'
error 13:13:8.469: Error in execution [i [Error]: Jupyter cannot be started. Error attempting to locate Jupyter: Running cells with 'Python 3.10.5 ('menv')' requires jupyter package.
	at S.startServer (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:98875)
	at processTicksAndRejections (node:internal/process/task_queues:96:5)
	at async S.createServer (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:97995)
	at async l.connect (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:75175)
	at async g.create (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:95736)
	at async p.createJupyterSession (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:160545)
	at async p.start (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:154488)
	at async Function.wrapKernelMethodImpl (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:336119)] {
  category: 'jupyterinstall'
}
error 13:13:8.469: Error in execution (get message for cell) [i [Error]: Jupyter cannot be started. Error attempting to locate Jupyter: Running cells with 'Python 3.10.5 ('menv')' requires jupyter package.
	at S.startServer (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:98875)
	at processTicksAndRejections (node:internal/process/task_queues:96:5)
	at async S.createServer (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:97995)
	at async l.connect (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:75175)
	at async g.create (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:95736)
	at async p.createJupyterSession (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:160545)
	at async p.start (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:154488)
	at async Function.wrapKernelMethodImpl (/Users/myuser/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/out/extension.node.js:24:336119)] {
  category: 'jupyterinstall'
}

@michaelweinold michaelweinold added the bug Issue identified by VS Code Team member as probable bug label Jul 19, 2022
@github-actions github-actions bot added the triage-needed Issue needs to be triaged label Jul 19, 2022
@michaelweinold
Copy link
Author

A complete clean re-install of VS Code and miniconda (including all environments) seems to resolve the issue.

@rchiodo
Copy link
Contributor

rchiodo commented Jul 19, 2022

Thanks for the bug.

When you did step 2: create a new virtual environment (python 3.9) and install jupyter

Did you create a new conda environment, or did you create a venv?

@avasyanin
Copy link

avasyanin commented Jul 19, 2022

The same issue with jupyter package. In my case it is conda environment (macOS Monterey 12.4 arm64, VSCode 1.69.2 arm64), but trying to install pip package also fails.

Catched exactly after VSCode update to the latest version.

@michaelweinold
Copy link
Author

Thanks for the bug.

When you did step 2: create a new virtual environment (python 3.9) and install jupyter

Did you create a new conda environment, or did you create a venv?

I used conda only, not venv or pyenv.

@rchiodo
Copy link
Contributor

rchiodo commented Jul 19, 2022

Hmm, it sounds like we're trying to use pip when we should use conda?

@avasyanin do you have the output logs? Can you tell if it's using pip to install?

@rchiodo
Copy link
Contributor

rchiodo commented Jul 19, 2022

Ah @avasyanin your problem is different. Conda isn't setup to run. You need to run conda init bash first. Or install jupyter yourself.

@avasyanin
Copy link

@rchiodo, for conda env it tries to use conda, see log file attached.
jupyter.log

@avasyanin
Copy link

@rchiodo, probably it's the same, it worked well, nothing changed with conda before VSCode update. This issue happened only with VSCode update.

@rchiodo
Copy link
Contributor

rchiodo commented Jul 19, 2022

@avasyanin Your error is not the same as what @michaelweinold is seeing. Your system is failing to install because conda has not been initialized to support bash. If you create a conda terminal and then run conda init bash, it should fix our install.

@rchiodo
Copy link
Contributor

rchiodo commented Jul 19, 2022

@michaelweinold I'm not sure why yours was failing and since it's working now, I'm going to close this issue. From what I can tell running this:

/opt/miniconda3/envs/menv/bin/python -c "import jupyter"

Was failing even though the menv environment had jupyter installed.

If it repros again, we'd need the output from running that exact command.

We should probably log the stderr when it fails. This code here:

await this.deps.exec(info.command, info.args);

@rchiodo rchiodo closed this as completed Jul 19, 2022
@avasyanin
Copy link

@rchiodo you are right. conda init bash helped in my case. But how it worked before? Anyway, thanks for clarification!

@rchiodo
Copy link
Contributor

rchiodo commented Jul 19, 2022

But how it worked before?

We cache the 'jupyter' environment we use. The cache may have been invalidated when updating VS code. So we no longer had the 'jupyter' environment to use and had to find/make a new one. This making of a new one seems to be where it was failing for you.

@AnushaNTNU
Copy link

I am getting the same error. Again after reinstalling VS code. I dont know why i get this error repeatedly

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 11, 2023
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 triage-needed Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

4 participants