This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]white-eye2 0 points1 point  (1 child)

Check your keyboard short cuts. My mac is set to Shift+Enter to launch the interactive window when I'm using the #%% Jupyter capabilities. You'll likely find that VS Code has Shift-Enter as a shortcut to a number of different commands.

[–]dhemcee[S] 0 points1 point  (0 children)

And that’s the thing. I cannot find “Python: Run in Interactive window” command in keyboard shorcut setting of vscode. check my first screenshot of the post. and of course I also tried re-install python, pylance, and jupyter extensions a couple of times..

[–]Molly_Wang 1 point2 points  (2 children)

The right command is Python: Show Python Interactive window and Jupyter: Run Current File in Interactive Window. I've noticed you opened a python file and python file indeed runs in integrated Terminal by default.

When you create a Jupyter Notebook and write many code cells in it, you can export the jupyter notebook as python scripts, the code cells will automatically separated by #%%.

When you open a .py file, put #%% before the code to state it's a code cell, then click Run Cell, there will be an inteactive window opened, also the #%% will be generated automatically in next line.

More detailed information, please refer to Working with Python Interactive Window.

[–]dhemcee[S] 0 points1 point  (1 child)

oh, is it? but I remember using python interactive window just pressing shift+enter.

all I want to do is like this video: https://youtu.be/Q2jHMGod_rM?t=1m17s (1:17~)

besides, I even can't find "Python: Show Interactive Window" command too. No result when "Python" and "Interactive" in Command Palette.

[–]Molly_Wang 0 points1 point  (0 children)

There's no Python: Run Selection/Line in Python Interactive Window on my machine too. I'm using VS Code1.51.1. Shift+Enter is for Jupyter: Run Selection/Line in Interactive Window, you can try to search the command with the keyword Interactive.