question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Run Cell" does not pickup on jupyter installed via virtualenv but conda works

See original GitHub issue

Environment data

  • VS Code version: 1.29.0 5f24c93878bd4bc645a4a17c620e2487b11005f9 x64

  • Extension version (available under the Extensions sidebar): 2018.10.1

  • OS and version: Ubuntu 18.04

  • Python version (& distribution if applicable, e.g. Anaconda): pipenv with python 3.7

  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): virtualenv

  • Relevant/affected Python packages and their versions: -

Actual behavior

When using a virtualenv/pipenv environment clicking on “Run Cell” yields the error msg: Running cells requires Jupyter notebooks to be installed.

(But it works with conda.)

Expected behavior

Cell is executed.

Steps to reproduce:

mkdir hello
cd hello
pipenv --python 3.7
pipenv shell
pipenv install jupyter
which jupyter
# /home/somebody/.local/share/virtualenvs/hello-UXM3mEkX/bin/jupyter
# jupyter notebook also works on its own

Open vscode, select the interpreter for the “hello” pipenv environment, create a file demo.py with the following content:

#%%
print("hello")

Clicking on “Run Cell” yields the error msg: Running cells requires Jupyter notebooks to be installed.

Relevant excerpt from Pipfile.lock

        "jupyter-client": {
            "version": "==5.2.3"
        },
        "jupyter-console": {
            "version": "==6.0.0"
        },
        "jupyter-core": {
            "version": "==4.4.0"
        },

Logs

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

No output.

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

/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Error: Error executing Jupyter command 'nbconvert': [Errno 2] No such file or directory

t.log @ /usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Error: Running cells requires Jupyter notebooks to be installed.
t.log @ /usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:2429 Running cells requires Jupyter notebooks to be installed.

nbconvert is not available via the venv, but jupyter-nbconvert is.

Maybe Related

See https://github.com/Microsoft/vscode-python/issues/3341 and https://github.com/Microsoft/vscode-python/issues/3332

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
sottecommented, Nov 14, 2018

Update: It seem to be related to how you start vscode.

  • When vscode is started from the activated virtualenv code . then “run cell” works.
  • When vscode is started without any environment (and jupyter is not available in the current PATH)
    • “run cell” works with a conda interpreter
    • “run cell” does not work with the interpreter from the virtualenv

conda and virtualenv seem to be handled differently. Is this a bug or accepted behavior?

0reactions
leonjonathancommented, Dec 10, 2018

@rchiodo Yes, works as expected when starting code with environment activated in terminal. Not using pipenv though (as in microsoft/vscode-jupyter#3774). If I understand correctly, pipenv uses VirtualEnv, while pyenv-virtualenv uses native python3 -m venv despite its name

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Run Cell" does not pickup on jupyter installed via virtualenv ...
Running cells requires Jupyter notebooks to be installed. (But it works with conda.) Expected behavior. Cell is executed. Steps to reproduce:.
Read more >
Jupyter notebooks in Visual Studio Code does not use the ...
Python code works perfectly fine, but Jupyter refuses to pick up the local .venv . The local venv is in Python: Select Interpreter...
Read more >
Get Your Conda Environment to Show in Jupyter Notebooks
1. First, install nb_conda_kernels in your base environment. Once this is installed any notebook running from the base environment will ...
Read more >
Introduction to Python environments — Using Python for Science
If you install a library with conda or pip, it will end up in one of these folders. If it's not there, or...
Read more >
Set up virtual environment for Python using Anaconda
Head over to anaconda.com and install the latest version of Anaconda. Make sure to download the “Python 3.7 Version” for the appropriate ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found