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.

Kernel picker doesn't find venv installed ipykernels when setting 'defaultInterpreterPath'

See original GitHub issue

Applies To

  • Notebooks (.ipynb files)
  • Interactive Window and/or Cell Scripts (.py files with #%% markers)

What happened?

Installed kernels under venv don’t show up in kernel pick list even after selecting venv as the main python interpreter.

jupyter kernelspec list
Available kernels:
  python3                             /Users/username/workspace/repo/.vscode/src_python_twitter_ml_tfx__tfx/venv/share/jupyter/kernels/python3
  src_python_twitter_ml_tfx__tfx      /Users/gcasassaez/workspace/repo/.vscode/src_python_twitter_ml_tfx__tfx/venv/share/jupyter/kernels/src_python_twitter_ml_tfx__tfx

However src_python_twitter_ml_tfx__tfx doesn’t appear within the list in the kernel picker.

VS Code Version

Version: 1.66.2 Commit: dfd34e8260c270da74b5c2d86d61aee4b6d56977 Date: 2022-04-11T07:49:20.994Z Electron: 17.2.0 Chromium: 98.0.4758.109 Node.js: 16.13.0 V8: 9.8.177.11-electron.0 OS: Darwin x64 21.3.0

Jupyter Extension Version

v2022.3.1000901801

Jupyter logs

Visual Studio Code (1.66.2, undefined, desktop)
Jupyter Extension Version: 2022.3.1000901801.
Python Extension Version: 2022.4.1.
Multiple Workspace folders opened ~/workspace/source3/src/python, ~/workspace/source3
Info 17:29:00: ZMQ install verified.
User belongs to experiment group 'jupyterTestcf'
User belongs to experiment group 'jupyterEnhancedDataViewer'
Info 17:29:00: Old kernelspecs (created by Jupyter extension) stored in directory /Users/gcasassaez/Library/Jupyter/kernels/__old_vscode_kernelspecs
Info 17:29:01: Experiment status for python is {"enabled":true,"optInto":[],"optOutFrom":[]}
Info 17:29:01: Creating controller for jupyter-notebook with interpreter ~/workspace/source3/.vscode/src_python_twitter_ml_tfx__tfx/venv/bin/python
Info 17:29:01: Find preferred kernel for ~/workspace/source3/src/python/twitter/ml/tfx/examples/nb/quickstart.ipynb with metadata {"interpreter":{"hash":"2a20e6adaa8bffcd05bfe6ddb269ab947538bbfcb1d8ac9fca255e704b4bda27"},"kernelspec":{"display_name":"Python 3.7.9 64-bit ('venv': venv)","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.7.9"},"metadata":{"interpreter":{"hash":"2a20e6adaa8bffcd05bfe6ddb269ab947538bbfcb1d8ac9fca255e704b4bda27"}},"mldash_entity":{"created_at_millis":1621969349661,"hash":"0381c815889b5b803752fa503e425d6e7cd13a2d","inferred_pdp_safe":false,"is_vfs_dir":false,"marked_pdp_safe":false,"owner":"ddavydov","shared_to_everyone":false,"shared_to_ldap_groups":[],"shared_to_ldap_users":[],"size":38240,"tags":[],"uuid":"1397266841681088513","vfs_path":"/user/ddavydov/AIPT Docs/quickstart.ipynb"},"papermill":{"duration":407.767125,"end_time":"2020-09-24T18:04:03.852847","environment_variables":{},"exception":null,"input_path":"ns:///user/cortex/.quickstart-a3_1cb48a2aedec04631626dd60a51daa49983602d7.ipynb","output_path":"ns:///user/anonymous/.quickstart-a3_1cb48a2aedec04631626dd60a51daa49983602d7_2020-09-24T17_57_09.ipynb","parameters":{},"start_time":"2020-09-24T17:57:16.085722","version":"2.1.1"},"record_timing":true} & preferred interpreter ~/workspace/source3/.vscode/src_python_twitter_ml_tfx__tfx/venv/bin/python
Info 17:29:01: findKernel found Python 3.9.10 64-bit
Info 17:29:01: PreferredConnection: .jvsc74a57bd0aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49./usr/local/bin/python3./usr/local/bin/python3.-m#ipykernel_launcher found for NotebookDocument: ~/workspace/source3/src/python/twitter/ml/tfx/examples/nb/quickstart.ipynb
Info 17:29:01: TargetController found ID: .jvsc74a57bd0aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49./usr/local/bin/python3./usr/local/bin/python3.-m#ipykernel_launcher for document ~/workspace/source3/src/python/twitter/ml/tfx/examples/nb/quickstart.ipynb
Info 17:29:01: Setting controller affinity for ~/workspace/source3/src/python/twitter/ml/tfx/examples/nb/quickstart.ipynb .jvsc74a57bd0aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49./usr/local/bin/python3./usr/local/bin/python3.-m#ipykernel_launcher
Info 17:29:01: Getting activation commands for /usr/local/bin/python3 are not cached. May take a while.
Info 17:29:01: Process Execution: > ~/workspace/source3/.vscode/src_python_twitter_ml_tfx__tfx/venv/bin/python -m pip list
> ~/workspace/source3/.vscode/src_python_twitter_ml_tfx__tfx/venv/bin/python -m pip list
Info 17:29:02: Setting setActiveController for ~/workspace/source3/src/python/twitter/ml/tfx/examples/nb/quickstart.ipynb
Info 17:29:02: KernelProvider switched kernel to id = .jvsc74a57bd014f2b09c6503f1cb0a20977a1ae94d6c872dee03042d416d44ea707538c50c60./Users/gcasassaez/workspace/source3/.vscode/src_python_twitter_ml_tfx__tfx/venv/python./Users/gcasassaez/workspace/source3/.vscode/src_python_twitter_ml_tfx__tfx/venv/python.-m#ipykernel_launcher
Info 17:29:02: Starting Notebook in kernel.ts id = .jvsc74a57bd014f2b09c6503f1cb0a20977a1ae94d6c872dee03042d416d44ea707538c50c60./Users/gcasassaez/workspace/source3/.vscode/src_python_twitter_ml_tfx__tfx/venv/python./Users/gcasassaez/workspace/source3/.vscode/src_python_twitter_ml_tfx__tfx/venv/python.-m#ipykernel_launcher for ~/workspace/source3/src/python/twitter/ml/tfx/examples/nb/quickstart.ipynb
Info 17:29:02: Creating raw notebook for ~/workspace/source3/src/python/twitter/ml/tfx/examples/nb/quickstart.ipynb
Info 17:29:02: Getting preferred kernel for ~/workspace/source3/src/python/twitter/ml/tfx/examples/nb/quickstart.ipynb
Info 17:29:02: Computing working directory ~/workspace/source3/src/python/twitter/ml/tfx/examples/nb/quickstart.ipynb
Info 17:29:02: Starting raw kernel Python 3.7.9 64-bit for interpreter ~/workspace/source3/.vscode/src_python_twitter_ml_tfx__tfx/venv/bin/python
Info 17:29:02: Kernel launching with ports 9000,9001,9002,9003,9004. Start port is 9000
Info 17:29:02: Registering dummy command feature
Info 17:29:02: Process Execution: > ~/workspace/source3/.vscode/src_python_twitter_ml_tfx__tfx/venv/bin/python -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
> ~/workspace/source3/.vscode/src_python_twitter_ml_tfx__tfx/venv/bin/python -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
Info 17:29:02: Adding env Variable PYTHONNOUSERSITE to ~/workspace/source3/.vscode/src_python_twitter_ml_tfx__tfx/venv/bin/python
Info 17:29:02: Process Execution: > ~/workspace/source3/.vscode/src_python_twitter_ml_tfx__tfx/venv/bin/python -m ipykernel_launcher --ip=127.0.0.1 --stdin=9003 --control=9001 --hb=9000 --Session.signature_scheme="hmac-sha256" --Session.key=b"79abd7a3-ebd8-46ae-a9b3-b1ef0b20d76a" --shell=9002 --transport="tcp" --iopub=9004 --f=/var/folders/6w/jgs_lvqj0cd3mc418q5b193r0000gp/T/tmp-97547tJta2MNMVJa8.json
> ~/workspace/source3/.vscode/src_python_twitter_ml_tfx__tfx/venv/bin/python -m ipykernel_launcher --ip=127.0.0.1 --stdin=9003 --control=9001 --hb=9000 --Session.signature_scheme="hmac-sha256" --Session.key=b"79abd7a3-ebd8-46ae-a9b3-b1ef0b20d76a" --shell=9002 --transport="tcp" --iopub=9004 --f=/var/folders/6w/jgs_lvqj0cd3mc418q5b193r0000gp/T/tmp-97547tJta2MNMVJa8.json
Info 17:29:02: Process Execution: cwd: ~/workspace/source3/src/python/twitter/ml/tfx/examples/nb
cwd: ~/workspace/source3/src/python/twitter/ml/tfx/examples/nb
Info 17:29:03: ipykernel version 6.13.0 for ~/workspace/source3/.vscode/src_python_twitter_ml_tfx__tfx/venv/bin/python
Info 17:29:03: ipykernel location ~/workspace/source3/.vscode/src_python_twitter_ml_tfx__tfx/venv/lib/python3.7/site-packages/ipykernel/__init__.py for ~/workspace/source3/.vscode/src_python_twitter_ml_tfx__tfx/venv/bin/python
Info 17:29:03: Process Execution: > /usr/local/bin/python3 -m pip list
> /usr/local/bin/python3 -m pip list
Warn 17:29:05: StdErr from Kernel Process /Users/gcasassaez/workspace/source3/.vscode/src_python_twitter_ml_tfx__tfx/venv/lib/python3.7/site-packages/traitlets/traitlets.py:2205: FutureWarning: Supporting extra quotes around strings is deprecated in traitlets 5.0. You can use 'hmac-sha256' instead of '"hmac-sha256"' if you require traitlets >=5.
  FutureWarning)
/Users/gcasassaez/workspace/source3/.vscode/src_python_twitter_ml_tfx__tfx/venv/lib/python3.7/site-packages/traitlets/traitlets.py:2160: FutureWarning: Supporting extra quotes around Bytes is deprecated in traitlets 5.0. Use '79abd7a3-ebd8-46ae-a9b3-b1ef0b20d76a' instead of 'b"79abd7a3-ebd8-46ae-a9b3-b1ef0b20d76a"'.
  FutureWarning)

Info 17:29:05: Kernel Output: NOTE: When using the `ipython kernel` entry point, Ctrl-C will not work.

To exit, you will have to explicitly quit this process, by either sending
"quit" from a client, or using Ctrl-\ in UNIX-like environments.

To read more about this, see https://github.com/ipython/ipython/issues/2049


To connect another client to this kernel, use:
    --existing /var/folders/6w/jgs_lvqj0cd3mc418q5b193r0000gp/T/tmp-97547tJta2MNMVJa8.json

Info 17:29:05: Raw session started and connected
Started kernel Python 3.7.9 64-bit
Info 17:29:05: Finished connecting c69e3ee4-cdc4-4bad-8791-9915c341c596
Info 17:29:05: UpdateWorkingDirectoryAndPath in Kernel
Info 17:29:05: Executing silently Code (idle) = import site\nsite.addsitedir(site.getusersitepackages())\nimport os\nimport sys\n%cd "/Users/gcasassaez/
Info 17:29:05: Executing silently Code (completed) = import site\nsite.addsitedir(site.getusersitepackages())\nimport os\nimport sys\n%cd "/Users/gcasassaez/
Info 17:29:05: Waiting for idle on (kernel): 8da1de87-84e8-40f8-b5f4-1452246286fe -> idle
Info 17:29:05: Finished waiting for idle on (kernel): 8da1de87-84e8-40f8-b5f4-1452246286fe -> idle

Coding Language and Runtime Version

Python 3.7

Language Extension Version (if applicable)

No response

Anaconda Version (if applicable)

No response

Running Jupyter locally or remotely?

Local

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:22 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
rchiodocommented, Apr 21, 2022

can we wait until extension is released before closing?

We follow the pattern that the VS code team does. Bugs are closed when fixed by a PR. A ‘verified’ label is added when it’s been tested to have been released in our preview bits.

0reactions
DonJayamannecommented, Apr 21, 2022

This has been fixed in the latest pre-release version of the Jupyter extension.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jupyter notebooks in Visual Studio Code does not use the ...
I find it easy to use pipenv install ipykernel to set up the virtual environment with the Jupyter kernel in one go (comment...
Read more >
How To Setup Jupyter Notebook in VS Code (w/ Virtual Env ...
Step 1. Create project folder · Step 2. Create, activate & select your virtual environment · Step 3. Install ipykernel · Step 4....
Read more >
Set up a working environment | DataSpell Documentation
Install packages using the environment settings · In the Python interpreter selector, select Interpreter Settings. · Select the target ...
Read more >
How to select venv for notebook kernel : r/vscode - Reddit
To select an environment, use the Python: Select Interpreter command from the Command Palette (Ctrl+Shift+P). So please check if your venv is ...
Read more >
How do I create a virtual environment on the Jupyter server?
If your Pipfile doesn't include ipykernel, run this code (it may take a few minutes). pipenv install ipykernel. 3) Activate! Then you can...
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