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.

Interactive window selects the wrong interpreter in multi folder workspace

See original GitHub issue

Bug: Notebook Editor, Interactive Window, Editor cells

Steps to cause the bug to occur

  1. Open a workspace with multiple folders and each has a different Python interpreter.

    • From folder settings of first folder:
      "python.pythonPath": "/Users/ironfoot/.local/share/virtualenvs/hub-aNnxaMau/bin/python"
      
    • From folder settings of the folder I’m trying to run interactive window:
      "python.pythonPath": "/usr/local/Caskroom/miniconda/base/envs/turihub/bin/python",
      
  2. Install jupyter in the folder I’m trying to run interactive window.

    (turihub) [ironfoot@:~] pip show ipykernel
    Name: ipykernel
    Version: 5.3.4
    Summary: IPython Kernel for Jupyter
    Home-page: https://ipython.org
    Author: IPython Development Team
    Author-email: ipython-dev@scipy.org
    License: BSD
    Location: /usr/local/Caskroom/miniconda/base/envs/turihub/lib/python3.8/site-packages
    Requires: tornado, appnope, jupyter-client, ipython, traitlets
    Required-by: qtconsole, notebook, jupyter, jupyter-console, ipywidgets
    
  3. Open a Python file from a folder that has jupyter installed.

  4. Right click on the file and select “Run current file in Python Interactive Window”.

Actual behavior

  • Popup that says “Data Science library ipykernel is not installed. Install?”
  • If I click yes, same popup appears again.
  • If I click yes again, “Could not install ipykernel. If pip is not available, please use the package manager of your choice to manually install this library into your Python environment.”
  • Toggle developer window > Console
Could not install ipykernel. If pip is not available, please use the package manager of your choice to manually install this library into your Python environment.
... omitted ...
IPyKernel not installed into interpreter Python 3.7.4 64-bit ('hub': pipenv)

Here, “hub” is the pipenv setup in the first folder which does not have jupyter.

Expected behavior

VSCode should have used the interpreter in the currently opened file/folder which does have jupyter installed.

Your Jupyter and/or Python environment

  • Jupyter server running: N/A (meant to be local but never started)
  • Extension version: 2020.8.109390
  • VS Code version: 1.49.1
  • Setting python.jediEnabled: false
  • Setting python.languageServer: Pylance
  • Python and/or Anaconda version: The first folder: Python 3.7.4, The folder I’m running in: Python 3.8.5
  • OS: Mac
  • Virtual environment: The first folder: venv, The folder I’m running in: conda

Python Output

Copying just the tail end, entire thing is very long.

Info 2020-09-22 12:43:23: > pipenv --venv
> pipenv --venv
Info 2020-09-22 12:43:23: cwd: ~/workspace/hub
cwd: ~/workspace/hub
Info 2020-09-22 12:43:23: Get Interpreters in CacheableLocatorService, Class name = f, completed in 0ms, has a truthy return value, Arg 1: undefined, Arg 2: undefined, Return Value: [{"architecture":3,"path":"/Users/ironfoot/.local/share/virtualenvs/hub-aNnxaMau/bin/python","version":{"options":{"loose":false,"includePrerelease":false},"loose":false,"raw":"3.7.4-final","major":3,"minor":7,"patch":4,"prerelease":["final"],"build":[],"version":"3.7.4-final"},"sysPrefix":"/Users/ironfoot/.local/share/virtualenvs/hub-aNnxaMau","fileHash":"024a89abee11e89f0bfd98af069408a54ffdf6c1bbc4baf873f7bae10ccb57273a1c7e787a21b5a2b820a70088ae5feca18d6c63c8736f63328c0d06fd995edd","type":"PipEnv","pipEnvWorkspaceFolder":"/Users/ironfoot/workspace/hub","cachedEntry":true}]
Info 2020-09-22 12:43:23: Shutdown session -- complete
Error 2020-09-22 12:43:23: DataScience Error [Error: IPyKernel not installed into interpreter Python 3.7.4 64-bit ('hub': pipenv)
	at D.verifyIpyKernel (/Users/ironfoot/.vscode/extensions/ms-python.python-2020.8.109390/out/client/extension.js:56:535048)
	at runMicrotasks (<anonymous>)
	at processTicksAndRejections (internal/process/task_queues.js:94:5)]
Error 2020-09-22 12:43:23: DataScience Error [Error: IPyKernel not installed into interpreter Python 3.7.4 64-bit ('hub': pipenv)
	at D.verifyIpyKernel (/Users/ironfoot/.vscode/extensions/ms-python.python-2020.8.109390/out/client/extension.js:56:535048)
	at runMicrotasks (<anonymous>)
	at processTicksAndRejections (internal/process/task_queues.js:94:5)]
Error 2020-09-22 12:43:23: DataScience Error [Error: IPyKernel not installed into interpreter Python 3.7.4 64-bit ('hub': pipenv)
	at D.verifyIpyKernel (/Users/ironfoot/.vscode/extensions/ms-python.python-2020.8.109390/out/client/extension.js:56:535048)
	at runMicrotasks (<anonymous>)
	at processTicksAndRejections (internal/process/task_queues.js:94:5)]
Info 2020-09-22 12:43:23: Cached data exists getEnvironmentVariables, /Users/ironfoot/workspace/hub
Info 2020-09-22 12:43:23: > pipenv --py
> pipenv --py
Info 2020-09-22 12:43:23: cwd: ~/workspace/hub
cwd: ~/workspace/hub
Info 2020-09-22 12:43:24: Interpreters returned by PipEnvService are of count 1
Info 2020-09-22 12:43:24: Interpreters returned by PipEnvService are [{"architecture":3,"path":"/Users/ironfoot/.local/share/virtualenvs/hub-aNnxaMau/bin/python","version":{"options":{"loose":false,"includePrerelease":false},"loose":false,"raw":"3.7.4-final","major":3,"minor":7,"patch":4,"prerelease":["final"],"build":[],"version":"3.7.4-final"},"sysPrefix":"/Users/ironfoot/.local/share/virtualenvs/hub-aNnxaMau","fileHash":"024a89abee11e89f0bfd98af069408a54ffdf6c1bbc4baf873f7bae10ccb57273a1c7e787a21b5a2b820a70088ae5feca18d6c63c8736f63328c0d06fd995edd","type":"PipEnv","pipEnvWorkspaceFolder":"/Users/ironfoot/workspace/hub"}]
Info 2020-09-22 12:43:24: Checking whether locactors have completed locating, Class name = p, completed in 0ms, has a truthy return value, , Return Value: true
Info 2020-09-22 12:43:24: Hide locator refreshing progress, Class name = p, completed in 0ms, has a falsy return value, , Return Value: undefined
Info 2020-09-22 12:43:24: All locators have completed locating, Class name = p, completed in 0ms, has a falsy return value, , Return Value: undefined
Info 2020-09-22 12:43:32: Cached data exists getEnvironmentVariables, tasks
Info 2020-09-22 12:43:35: Cached data exists getEnvironmentVariables, /Users/ironfoot/workspace/playground
Info 2020-09-22 12:43:35: Cached data exists getEnvironmentVariables, extension-output-#5
Python interpreter path: /usr/local/Caskroom/miniconda/base/envs/turihub/bin/python
Python interpreter path: ~/.local/share/virtualenvs/hub-aNnxaMau/bin/python

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
okngneercommented, Sep 22, 2020

@IanMatthewHuff To be exact I am seeing two different issues at the same time. One is that the wrong interpreter is selected which is what I described above. The other is that even if the wrong interpreter is selected it shouldn’t fail installing ipykernel which it what you described.

Attaching the logs.

python.log

0reactions
okngneercommented, Sep 24, 2020

This is weird. I tried what you said and it works correctly. Then I closed VSCode, restarted it as I usually do with spotlight search, and it works correctly. The only thing I really did is installing ‘code’ in path (through command palette). I’ll see if I can create a minimal example to reproduce the issue. But otherwise, the issue disappeared. Either way, thanks for looking into this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

VSCode loads the wrong python version in the interactive ...
If you open a new .ipynb file in the VSCode which name has not storaged in the database, you will need to select...
Read more >
Settings Reference for Python - Visual Studio Code
Python settings reference. The Python Extension for Visual Studio Code is highly configurable. This page describes the key settings you can work with....
Read more >
Manage Python environments and interpreters - Visual Studio ...
Use the Python Environments window to manage global, virtual, and conda environments. Install Python interpreters and packages and assign ...
Read more >
How to Set Up Visual Studio Code in 2022 (The Easy Way)
Select the recommended Python interpreter. If you have multiple Python versions installed on your Mac, choose the latest version:
Read more >
A comprehensive guide to debugging Python scripts in VS Code
And don't get me wrong, the Notebooks are a great tool for data ... %debug to open the interactive debugger window within Jupyter...
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