Search code examples
pythonvisual-studio-codejupyter-notebookpython-interactive

Why does VS Code require the Jupyter extension to run Python interactively, even for .py files?


I've noticed that when trying to run Python code interactively in VS Code (e.g., executing code cells in .py files), VS Code prompts me to install the Jupyter extension.

enter image description here

This seems strange because I have ipykernel and IPython installed, and I would expect VS Code to run Python interactively without requiring Jupyter.

I'd appreciate any insight into this, as I'd prefer to avoid the extra overhead of the Jupyter extension if it's not necessary for my workflow.


Solution

  • This is the function called interacitve windows which is provided by Jupyter Notebook extension.

    The interactive window works like a jupyter notebook(.ipynb) file.

    If you want to use Python REPL in VSCode, you could open the Command Palette (Ctrl+Shift+P), select the Python: Start REPL command to open a REPL terminal for the currently selected Python interpreter. In the REPL, you can then enter and run lines of code one at a time.

    Read document for more details.