Skip to content

Requires Python 2.7 ipykernel to be installed when opening Python 3 notebook #4941

Closed
@ma137

Description

@ma137

Environment data

  • VS Code version: 1.53.2 (commit: 622cb03f7e070a9670c94bae1a45d78d7181fbd4)
  • Jupyter Extension version (available under the Extensions sidebar): v2021.2.576440691
  • Python Extension version (available under the Extensions sidebar): v2021.2.582707922
  • OS and version: Ubuntu 20.04 (Linux x64 5.4.0-66-generic)
  • Python and/or Anaconda version: Python 3.8.5 and Python 2.7.18
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A
  • Jupyter server running: Local

Detailed VS Code version information:

Version: 1.53.2
Commit: 622cb03f7e070a9670c94bae1a45d78d7181fbd4
Date: 2021-02-11T11:48:44.518Z
Electron: 11.2.1
Chrome: 87.0.4280.141
Node.js: 12.18.3
V8: 8.7.220.31-electron.0
OS: Linux x64 5.4.0-66-generic

Expected behaviour

Start automatically the IPython kernel for the trusted Python 3 notebook while opening the notebook. Run cells after clicking on the "Run cell" button.

(Before updating VS Code everything worked as expected.)

Actual behaviour

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, the cells do not get executed until one closes the error message by clicking on the "x".

Steps to reproduce:

  1. Start the Jupyter server by running jupyter notebook in a terminal. Open its web interface in a browser.
  2. Create a new Python 3 notebook. Add a cell or more, e.g. a cell with 1+1.
  3. Close the notebook in the web interface.
  4. Start VS Code and open the notebook. Try to run the cell with the "Run cell" button.

Here is a part of the source of one of my notebooks. As far as I know, these metadata show clearly that it is
a Python 3 notebook.

 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "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.8.5-final"
  },
  "toc-autonumbering": true
 },
 "nbformat": 4,
 "nbformat_minor": 4
}

Logs

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

> /usr/bin/python ~/.vscode/extensions/ms-toolsai.jupyter-2021.2.576440691/pythonFiles/pyvsc-run-isolated.py -c "import ipykernel" > /usr/bin/python ~/.vscode/extensions/ms-toolsai.jupyter-2021.2.576440691/pythonFiles/pyvsc-run-isolated.py -c "import ipykernel" Error 2021-02-24 20:00:40: Find kernel spec, Class name = L, completed in 40748ms, has a falsy return value, Arg 1: , Arg 2: {"kernelspec":{"display_name":"Python 3","language":"python","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.8.5"}}, Arg 3: undefined, Arg 4: undefined, Return Value: undefined [a [Error]: IPyKernel not installed into interpreter Python 2.7.18 64-bit:/usr/bin/python at L.installDependenciesIntoInterpreter (/home/ma/.vscode/extensions/ms-toolsai.jupyter-2021.2.576440691/out/client/extension.js:1:223195) at processTicksAndRejections (internal/process/task_queues.js:97:5) at async L.getKernelForLocalRawConnection (/home/ma/.vscode/extensions/ms-toolsai.jupyter-2021.2.576440691/out/client/extension.js:1:222022)] { category: 'noipykernel', reason: 1 } Error 2021-02-24 20:00:40: Get preferred local kernel connection, Class name = L, completed in 40749ms, has a falsy return value [a [Error]: IPyKernel not installed into interpreter Python 2.7.18 64-bit:/usr/bin/python at L.installDependenciesIntoInterpreter (/home/ma/.vscode/extensions/ms-toolsai.jupyter-2021.2.576440691/out/client/extension.js:1:223195) at processTicksAndRejections (internal/process/task_queues.js:97:5) at async L.getKernelForLocalRawConnection (/home/ma/.vscode/extensions/ms-toolsai.jupyter-2021.2.576440691/out/client/extension.js:1:222022)] { category: 'noipykernel', reason: 1 } Error 2021-02-24 20:00:40: Failed to determine if a notebook is active for the current editor [a [Error]: IPyKernel not installed into interpreter Python 2.7.18 64-bit:/usr/bin/python at L.installDependenciesIntoInterpreter (/home/ma/.vscode/extensions/ms-toolsai.jupyter-2021.2.576440691/out/client/extension.js:1:223195) at processTicksAndRejections (internal/process/task_queues.js:97:5) at async L.getKernelForLocalRawConnection (/home/ma/.vscode/extensions/ms-toolsai.jupyter-2021.2.576440691/out/client/extension.js:1:222022)] { category: 'noipykernel', reason: 1 } Error 2021-02-24 20:00:40: Failed to determine if a notebook is active for the current editor [a [Error]: IPyKernel not installed into interpreter Python 2.7.18 64-bit:/usr/bin/python at L.installDependenciesIntoInterpreter (/home/ma/.vscode/extensions/ms-toolsai.jupyter-2021.2.576440691/out/client/extension.js:1:223195) at processTicksAndRejections (internal/process/task_queues.js:97:5) at async L.getKernelForLocalRawConnection (/home/ma/.vscode/extensions/ms-toolsai.jupyter-2021.2.576440691/out/client/extension.js:1:222022)] { category: 'noipykernel', reason: 1 } Error 2021-02-24 20:00:40: DataScience Error [a [Error]: IPyKernel not installed into interpreter Python 2.7.18 64-bit:/usr/bin/python at L.installDependenciesIntoInterpreter (/home/ma/.vscode/extensions/ms-toolsai.jupyter-2021.2.576440691/out/client/extension.js:1:223195) at processTicksAndRejections (internal/process/task_queues.js:97:5) at async L.getKernelForLocalRawConnection (/home/ma/.vscode/extensions/ms-toolsai.jupyter-2021.2.576440691/out/client/extension.js:1:222022)] { category: 'noipykernel', reason: 1 } } Error 2021-02-24 20:01:20: Exception attempting to start notebook: [a [Error]: IPyKernel not installed into interpreter Python 2.7.18 64-bit:/usr/bin/python at L.installDependenciesIntoInterpreter (/home/ma/.vscode/extensions/ms-toolsai.jupyter-2021.2.576440691/out/client/extension.js:1:223195) at processTicksAndRejections (internal/process/task_queues.js:97:5) at async L.getKernelForLocalRawConnection (/home/ma/.vscode/extensions/ms-toolsai.jupyter-2021.2.576440691/out/client/extension.js:1:222022)] { category: 'noipykernel', reason: 1 } Error 2021-02-24 20:01:20: DataScience Error [a [Error]: IPyKernel not installed into interpreter Python 2.7.18 64-bit:/usr/bin/python at L.installDependenciesIntoInterpreter (/home/ma/.vscode/extensions/ms-toolsai.jupyter-2021.2.576440691/out/client/extension.js:1:223195) at processTicksAndRejections (internal/process/task_queues.js:97:5) at async L.getKernelForLocalRawConnection (/home/ma/.vscode/extensions/ms-toolsai.jupyter-2021.2.576440691/out/client/extension.js:1:222022)] { category: 'noipykernel', reason: 1 }

Possible origin of the problem

This output indicates that the problem might be that the extension executes /usr/bin/python also for Python 3 notebooks, while /usr/bin/python is actually Python 2 on Ubuntu 20.04. In the Ubuntu 20.04 release notes the following information can be found:

/usr/bin/python is not present by default on any new installs. On systems upgraded from previous releases, /usr/bin/python will continue to point to python2 for compatibility.

Screenshot

VS_Code_Jupyter_extension_error

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bug

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions