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

Run Cell fails to start Jupyter #3789

Closed
fdncred opened this issue Nov 14, 2018 · 5 comments · Fixed by microsoft/vscode-python#3506
Closed

Run Cell fails to start Jupyter #3789

fdncred opened this issue Nov 14, 2018 · 5 comments · Fixed by microsoft/vscode-python#3506
Assignees

Comments

@fdncred
Copy link

fdncred commented Nov 14, 2018

Similar to microsoft/vscode-python#3332 but with a different error message.

Environment data

  • VS Code version: 1.29.0
  • Extension version (available under the Extensions sidebar): 2018.10.1
  • OS and version: Windows 10 Enterprise 1809 OS Build 17763.55
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.7.0 64-bit, Anaconda
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): conda
  • Relevant/affected Python packages and their versions: N/A

Actual behavior

With this code

#%% [markdown]
# ## This is markdown
print("Hello World!")

It does not run cell and pops up an error dialog described below.

jupyter4

Expected behavior

I expect it to run python interactive and show the integrated jupyter notebook without errors.

Steps to reproduce:

Upon clicking "Run Cell", it tries to start jupyter, opens the "Python Interactive" window with blue progress bar, then shows a popup that says "Running cells requires Jupyter notebooks to be installed."

Jupyter is installed in my base and in my conda env. I can run "jupyter notebook" from the anaconda prompt and it starts fine from within the same conda env.
jupyter1

Logs

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

jupyter2

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

jupyter3

@amirhosseindavoody
Copy link

Same behavior here, except I don't see anything under Output->python panel.

@rchiodo rchiodo self-assigned this Nov 15, 2018
@rchiodo
Copy link
Contributor

rchiodo commented Nov 15, 2018

I believe this is the same issue as microsoft/vscode-python#3343. It's not picking up the right environment.

@fdncred
Copy link
Author

fdncred commented Nov 15, 2018

I can confirm that if I follow this in microsoft/vscode-python#3343 I can get Run Cell to work. It appears the key is launching vscode from within the activated conda environment. Thanks for the tip @rchiodo.

@amirhosseindavoody
Copy link

amirhosseindavoody commented Nov 15, 2018

Okay, I managed to get it to work, but it was a work around.

A little bit of background info:

I am using Windows 10 OS, and conda as the package manager.

I do not have anaconda path added to the environment variables so normally I cannot open command prompt and use jupyter or python commands. I have to use Anaconda prompt to run a python script or launch jupyter notebook.

Diagnosis

It seemed that when the python extension was trying to start jupyter server it was not using the right environment. My guess is that it was using standard command prompt to call jupyter and it wouldn't be able to find it since anaconda path was not added to environment variables.

Work around

I had to manually add the anaconda path (see below for the list of paths) to the environment variables

C:\Users\adavoody\AppData\Local\Continuum\anaconda3\envs\py37
C:\Users\adavoody\AppData\Local\Continuum\anaconda3\envs\py37\Library\mingw-w64\bin
C:\Users\adavoody\AppData\Local\Continuum\anaconda3\envs\py37\Library\usr\bin
C:\Users\adavoody\AppData\Local\Continuum\anaconda3\envs\py37\Library\bin
C:\Users\adavoody\AppData\Local\Continuum\anaconda3\envs\py37\Scripts
C:\Users\adavoody\AppData\Local\Continuum\anaconda3\envs\py37\bin
C:\Users\adavoody\AppData\Local\Continuum\anaconda3
C:\Users\adavoody\AppData\Local\Continuum\anaconda3\Library\mingw-w64\bin
C:\Users\adavoody\AppData\Local\Continuum\anaconda3\Library\usr\bin
C:\Users\adavoody\AppData\Local\Continuum\anaconda3\Library\bin
C:\Users\adavoody\AppData\Local\Continuum\anaconda3\Scripts
C:\Users\adavoody\AppData\Local\Continuum\anaconda3\bin;

@brettcannon
Copy link
Member

If there's a need to help reproduce, here is how I got my environment set up that can't detect Jupyter on Windows 10:

conda create --name <whatever> python=3.7
conda activate <whatever>
conda install numpy
conda install jupyter

This leads to the same traceback in Developer Tools as the OP:

  File "C:\Users\brcan\AppData\Local\Continuum\miniconda3\envs\numpytest\Scripts\jupyter-notebook-script.py", line 6, in <module>
    from notebook.notebookapp import main
  File "C:\Users\brcan\AppData\Local\Continuum\miniconda3\envs\numpytest\lib\site-packages\notebook\notebookapp.py", line 46, in <module>
    from zmq.eventloop import ioloop
  File "C:\Users\brcan\AppData\Local\Continuum\miniconda3\envs\numpytest\lib\site-packages\zmq\__init__.py", line 47, in <module>
    from zmq import backend
  File "C:\Users\brcan\AppData\Local\Continuum\miniconda3\envs\numpytest\lib\site-packages\zmq\backend\__init__.py", line 40, in <module>
    reraise(*exc_info)
  File "C:\Users\brcan\AppData\Local\Continuum\miniconda3\envs\numpytest\lib\site-packages\zmq\utils\sixcerpt.py", line 34, in reraise
    raise value
  File "C:\Users\brcan\AppData\Local\Continuum\miniconda3\envs\numpytest\lib\site-packages\zmq\backend\__init__.py", line 27, in <module>
    _ns = select_backend(first)
  File "C:\Users\brcan\AppData\Local\Continuum\miniconda3\envs\numpytest\lib\site-packages\zmq\backend\select.py", line 27, in select_backend
    mod = __import__(name, fromlist=public_api)
  File "C:\Users\brcan\AppData\Local\Continuum\miniconda3\envs\numpytest\lib\site-packages\zmq\backend\cython\__init__.py", line 6, in <module>
    from . import (constants, error, message, context,
ImportError: DLL load failed: The specified module could not be found.

But if I execute the script as python C:\Users\brcan\AppData\Local\Continuum\miniconda3\envs\numpytest\Scripts\jupyter-notebook-script.py from an activated conda environment then it works fine.

rchiodo referenced this issue in microsoft/vscode-python Nov 30, 2018
Run the conda activate script and scrape all of the environment from it prior to launching jupyter (or any other command with the same interpreter)
I'm hoping this will finally fix #3341.
@lock lock bot locked as resolved and limited conversation to collaborators Dec 28, 2018
@microsoft microsoft unlocked this conversation Nov 14, 2020
@DonJayamanne DonJayamanne transferred this issue from microsoft/vscode-python Nov 14, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants