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.

Extension does not detect installed ipykernel, uses wrong pip to try to install

See original GitHub issue

Environment data

  • VS Code version: 1.54.3
  • Jupyter Extension version (available under the Extensions sidebar): v2021.3.619093157
  • Python Extension version (available under the Extensions sidebar): v2021.3.658691958
  • OS (Windows | Mac | Linux distro) and version: macOS 11.2.3
  • Python and/or Anaconda version: 3.8.2
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): venv
  • Jupyter server running: Local

Steps to reproduce:

I am running a notebook in VSCode using a venv that has ipykernel installed, but the extension does not detect it and tries to install it anyway. Unfortunately, it tries to use pip rather than pip3, which results in a failure:

❯ /Users/cfonnesbeck/tensorflow_venv/bin/python /Users/cfonnesbeck/.vscode/extensions/ms-python.python-2021.3.658691958/pythonFiles/pyvsc-run-isolated.py /Users/cfonnesbeck/.vscode/extensions/ms-python.python-2021.3.658691958/pythonFiles/shell_exec.py /Users/cfonnesbeck/tensorflow_venv/bin/python /Users/cfonnesbeck/.vscode/extensions/ms-python.python-2021.3.658691958/pythonFiles/pyvsc-run-isolated.py pip install -U ipykernel --user /var/folders/40/_ljkntgn08g0vn2_s9gbxs340000gn/T/tmp-26279FPru7OEEFltb.log
Executing command in shell >> /Users/cfonnesbeck/tensorflow_venv/bin/python /Users/cfonnesbeck/.vscode/extensions/ms-python.python-2021.3.658691958/pythonFiles/pyvsc-run-isolated.py pip install -U ipykernel --user
ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv.
Traceback (most recent call last):
  File "/Users/cfonnesbeck/.vscode/extensions/ms-python.python-2021.3.658691958/pythonFiles/shell_exec.py", line 26, in <module>
    subprocess.check_call(shell_args, stdout=sys.stdout, stderr=sys.stderr)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/Users/cfonnesbeck/tensorflow_venv/bin/python', '/Users/cfonnesbeck/.vscode/extensions/ms-python.python-2021.3.658691958/pythonFiles/pyvsc-run-isolated.py', 'pip', 'install', '-U', 'ipykernel', '--user']' returned non-zero exit status 1.

running with pip3 confirms that it is installed in the venv, but the extension still does not detect it.

Again, I can guarantee that ipykernel is installed in the venv that I am using:

❯ ls ~/tensorflow_venv/lib/python3.8/site-packages/ipykernel*
/Users/cfonnesbeck/tensorflow_venv/lib/python3.8/site-packages/ipykernel_launcher.py

/Users/cfonnesbeck/tensorflow_venv/lib/python3.8/site-packages/ipykernel:
__init__.py         displayhook.py      jsonutil.py         resources
__main__.py         embed.py            kernelapp.py        serialize.py
_eventloop_macos.py eventloops.py       kernelbase.py       tests
_version.py         gui                 kernelspec.py       trio_runner.py
codeutil.py         heartbeat.py        log.py              zmqshell.py
comm                inprocess           parentpoller.py
connect.py          iostream.py         pickleutil.py
datapub.py          ipkernel.py         pylab

/Users/cfonnesbeck/tensorflow_venv/lib/python3.8/site-packages/ipykernel-5.5.0.dist-info:
COPYING.md    METADATA      REQUESTED     top_level.txt
INSTALLER     RECORD        WHEEL

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
DonJayamannecommented, Mar 18, 2021

Thanks for filing this issue.

Please could you enable logging as follows:

  • Open settings & go into Jupyter->Logging
  • Change the value to debug
  • Reload VS Code,
  • Attempt to repro the issue & then copy the output from the Jupyter output panel.

After you have the logs from Jupyter panel, please try the following:

  • Install VS Code Insiders
  • Install the Jupyter extension
  • Try this once again

Basically when you install the Jupyter extension in VS Code Insiders, you’ll get the latest development version of the Jupyter extension & we have fixed a number of issues related to IPYkernel in tehre. If the problem persists, we’ll need to dig into this further.

0reactions
greazercommented, Apr 23, 2021

Closing due to no response in over a week.

Read more comments on GitHub >

github_iconTop Results From Across the Web

IPyKernel not installed into interpreter Python 3.8.6 64-bit #1093
Open a terminal · Activate the environemtn · Run the command python -m ipykernel --version · Try manually running python -m pip install...
Read more >
Python requires ipykernel to be installed - Stack Overflow
I hit the pop up to install and can see the following being installed in the selected virtual environment/kernel i am using with...
Read more >
What to do when things go wrong - The Jupyter Notebook
If Jupyter gives an error that it can't find notebook , check with pip or conda that the notebook package is installed. Try...
Read more >
Fix Anaconda + Jupyter Notebook "module not found" errors ...
Did you install Anaconda but Jupyter Notebook can't find Anaconda? Or you run Jupyter but nothing seems to be installed ?
Read more >
running cells with 'python 3.10.4 64-bit' requires ipykernel ...
Error message "Python 2.7.18 64-bit requires ipykernel to be installed." appears at startup and each time one tries to run a cell. Actually,...
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