microsoft / vscode-jupyter

VS Code Jupyter extension
https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter
MIT License
1.3k stars 293 forks source link

Shift+Enter shortcut for `jupyter.execSelectionInteractive` captured by `python.execSelectionInTerminal` #13289

Closed Antyos closed 1 year ago

Antyos commented 1 year ago

Applies To

What happened?

Using the shortcut shift+enter to run the selected lines of code when an interactive window is open for a .py file attempts to run the code in a new python instance from the command line instead of in the interactive window.

My guess is that the when clauses are not correct for the shift+enter keyboard shortcut. So even though an interactive window is open, shift+enter triggers python.execSelectionInTerminal instead of jupyter.execSelectionInteractive. This is very annoying because the new Python instance in the terminal (obviously) has no awareness of the variables in the interactive window.

VS Code Version

Version: 1.77.1 (user setup) Commit: b7886d7461186a5eac768481578c1d7ca80e2d21 Date: 2023-04-04T23:21:11.906Z Electron: 19.1.11 Chromium: 102.0.5005.196 Node.js: 16.14.2 V8: 10.2.154.26-electron.0 OS: Windows_NT x64 10.0.19044 Sandboxed: No

Jupyter Extension Version

v2023.3.1000892223

Jupyter logs

Visual Studio Code (1.77.1, undefined, desktop)
Jupyter Extension Version: 2023.3.1000892223.
Python Extension Version: 2023.6.0.
Workspace folder c:\Users\Andrew\Code\dcns-project
User belongs to experiment group 'jupyterEnhancedDataViewer'
User belongs to experiment group 'jupyterTest'
info 12:59:12.934: LSP Notebooks experiment is enabled
info 12:59:15.227: Process Execution: > ~\Code\dcns-project\.venv\Scripts\python.exe -m pip list
> ~\Code\dcns-project\.venv\Scripts\python.exe -m pip list
info 12:59:21.751: Starting interactive window for resource '' with controller '.jvsc74a57bd0bb4cc3fbedaecb582e483d153fbd4f83c8b0b658f75778324ffe08ec6274668a.c:\Users\Andrew\Code\dcns-project\.venv\Scripts\python.exe.c:\Users\Andrew\Code\dcns-project\.venv\Scripts\python.exe.-m#ipykernel_launcher (Interactive)'
info 12:59:22.090: Starting Jupyter Session startUsingPythonInterpreter, .jvsc74a57bd0bb4cc3fbedaecb582e483d153fbd4f83c8b0b658f75778324ffe08ec6274668a.c:\Users\Andrew\Code\dcns-project\.venv\Scripts\python.exe.c:\Users\Andrew\Code\dcns-project\.venv\Scripts\python.exe.-m#ipykernel_launcher (Python Path: c:\Users\Andrew\Code\dcns-project\.venv, EnvType: Poetry, EnvName: '.venv', Version: 3.9.12 (tags/v3.9.12:b28265d, Mar 23 2022, 23:52:46) [MSC v.1929 64 bit (AMD64)]) for 'Interactive-1.interactive' (disableUI=false)
info 12:59:22.319: Process Execution: > ~\Code\dcns-project\.venv\Scripts\python.exe -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
> ~\Code\dcns-project\.venv\Scripts\python.exe -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
warn 12:59:22.384: Failed to get activated env vars for c:\Users\Andrew\AppData\Local\Programs\Python\Python310\python.exe in 10ms
info 12:59:22.413: Process Execution: > ~\AppData\Local\Programs\Python\Python310\python.exe -c "import site;print("USER_BASE_VALUE");print(site.USER_SITE);print("USER_BASE_VALUE");"
> ~\AppData\Local\Programs\Python\Python310\python.exe -c "import site;print("USER_BASE_VALUE");print(site.USER_SITE);print("USER_BASE_VALUE");"
info 12:59:22.531: ipykernel version & path 6.21.3, ~\Code\dcns-project\.venv\lib\site-packages\ipykernel\__init__.py for c:\Users\Andrew\Code\dcns-project\.venv\Scripts\python.exe
info 12:59:22.543: Process Execution: > ~\AppData\Local\Programs\Python\Python310\python.exe ~\.vscode\extensions\ms-toolsai.jupyter-2023.3.1000892223\pythonFiles\vscode_datascience_helpers\kernel_interrupt_daemon.py --ppid 77996
> ~\AppData\Local\Programs\Python\Python310\python.exe ~\.vscode\extensions\ms-toolsai.jupyter-2023.3.1000892223\pythonFiles\vscode_datascience_helpers\kernel_interrupt_daemon.py --ppid 77996
info 12:59:22.543: Process Execution: cwd: ~\.vscode\extensions\ms-toolsai.jupyter-2023.3.1000892223\pythonFiles\vscode_datascience_helpers
cwd: ~\.vscode\extensions\ms-toolsai.jupyter-2023.3.1000892223\pythonFiles\vscode_datascience_helpers
info 12:59:22.667: Process Execution: > ~\Code\dcns-project\.venv\Scripts\python.exe -m ipykernel_launcher --ip=127.0.0.1 --stdin=9008 --control=9006 --hb=9005 --Session.signature_scheme="hmac-sha256" --Session.key=b"90ac1137-5cf7-445b-9cbf-d3903f013208" --shell=9007 --transport="tcp" --iopub=9009 --f=c:\Users\Andrew\AppData\Roaming\jupyter\runtime\kernel-v2-779967T9HLIVVYByG.json
> ~\Code\dcns-project\.venv\Scripts\python.exe -m ipykernel_launcher --ip=127.0.0.1 --stdin=9008 --control=9006 --hb=9005 --Session.signature_scheme="hmac-sha256" --Session.key=b"90ac1137-5cf7-445b-9cbf-d3903f013208" --shell=9007 --transport="tcp" --iopub=9009 --f=c:\Users\Andrew\AppData\Roaming\jupyter\runtime\kernel-v2-779967T9HLIVVYByG.json
info 12:59:22.667: Process Execution: cwd: ~\Code\dcns-project
cwd: ~\Code\dcns-project
info 12:59:24.075: Started Kernel .venv (Python 3.9.12) (pid: 66400)
info 12:59:24.173: Process Execution: > ~\Code\dcns-project\.venv\Scripts\python.exe ~\.vscode\extensions\ms-toolsai.jupyter-2023.3.1000892223\pythonFiles\printJupyterDataDir.py
> ~\Code\dcns-project\.venv\Scripts\python.exe ~\.vscode\extensions\ms-toolsai.jupyter-2023.3.1000892223\pythonFiles\printJupyterDataDir.py
warn 12:59:24.754: Failed to extract require.config from widget for arcgis from c:\Users\Andrew\.vscode\extensions\ms-toolsai.jupyter-2023.3.1000892223\tmp\scripts\3a586ec8e2ab9a18ebdc7eff4c34e01d8251fe13399a3083cdbd2eeccfa7c2e6\jupyter\nbextensions\arcgis\extension.js
info 12:59:28.662: Starting interactive window for resource 'c:\Users\Andrew\Code\dcns-project\sandbox.py' with controller '.jvsc74a57bd0bb4cc3fbedaecb582e483d153fbd4f83c8b0b658f75778324ffe08ec6274668a.c:\Users\Andrew\Code\dcns-project\.venv\Scripts\python.exe.c:\Users\Andrew\Code\dcns-project\.venv\Scripts\python.exe.-m#ipykernel_launcher (Interactive)'
info 12:59:28.994: Starting Jupyter Session startUsingPythonInterpreter, .jvsc74a57bd0bb4cc3fbedaecb582e483d153fbd4f83c8b0b658f75778324ffe08ec6274668a.c:\Users\Andrew\Code\dcns-project\.venv\Scripts\python.exe.c:\Users\Andrew\Code\dcns-project\.venv\Scripts\python.exe.-m#ipykernel_launcher (Python Path: c:\Users\Andrew\Code\dcns-project\.venv, EnvType: Poetry, EnvName: '.venv', Version: 3.9.12 (tags/v3.9.12:b28265d, Mar 23 2022, 23:52:46) [MSC v.1929 64 bit (AMD64)]) for 'Interactive-2.interactive' (disableUI=false)
info 12:59:28.999: Process Execution: > ~\Code\dcns-project\.venv\Scripts\python.exe -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
> ~\Code\dcns-project\.venv\Scripts\python.exe -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
info 12:59:29.036: Process Execution: > ~\Code\dcns-project\.venv\Scripts\python.exe -m ipykernel_launcher --ip=127.0.0.1 --stdin=9013 --control=9011 --hb=9010 --Session.signature_scheme="hmac-sha256" --Session.key=b"2203d863-5c01-47b2-bb39-457c6d30d091" --shell=9012 --transport="tcp" --iopub=9014 --f=c:\Users\Andrew\AppData\Roaming\jupyter\runtime\kernel-v2-77996V4w57N1aIx9v.json
> ~\Code\dcns-project\.venv\Scripts\python.exe -m ipykernel_launcher --ip=127.0.0.1 --stdin=9013 --control=9011 --hb=9010 --Session.signature_scheme="hmac-sha256" --Session.key=b"2203d863-5c01-47b2-bb39-457c6d30d091" --shell=9012 --transport="tcp" --iopub=9014 --f=c:\Users\Andrew\AppData\Roaming\jupyter\runtime\kernel-v2-77996V4w57N1aIx9v.json
info 12:59:29.036: Process Execution: cwd: ~\Code\dcns-project
cwd: ~\Code\dcns-project
info 12:59:29.215: ipykernel version & path 6.21.3, ~\Code\dcns-project\.venv\lib\site-packages\ipykernel\__init__.py for c:\Users\Andrew\Code\dcns-project\.venv\Scripts\python.exe
info 12:59:30.285: Started Kernel .venv (Python 3.9.12) (pid: 65660)
info 12:59:30.386: Generated code for 1 = <ipython-input-1-7f7dae7b1098> with 10 lines
warn 12:59:30.887: Failed to extract require.config from widget for arcgis from c:\Users\Andrew\.vscode\extensions\ms-toolsai.jupyter-2023.3.1000892223\tmp\scripts\3a586ec8e2ab9a18ebdc7eff4c34e01d8251fe13399a3083cdbd2eeccfa7c2e6\jupyter\nbextensions\arcgis\extension.js
info 12:59:31.835: Dispose Kernel 'Interactive-1.interactive' associated with 'Interactive-1.interactive'
info 12:59:31.837: Dispose Kernel process 66400.
info 12:59:31.842: Dispose Kernel 'Interactive-1.interactive' associated with 'Interactive-1.interactive'
info 12:59:33.853: Generated code for 2 = <ipython-input-2-e5c0b05cf87c> with 9 lines
info 13:08:08.433: Loading webview. View is notset
info 13:08:08.434: Loading web view...
info 13:08:08.434: Webview panel created.
info 13:08:08.590: Web view react rendered

Coding Language and Runtime Version

Python 3.9.12 (venv)

Language Extension Version (if applicable)

v2023.6.0

Anaconda Version (if applicable)

No response

Running Jupyter locally or remotely?

Local

amunger commented 1 year ago

can you check that you have the setting "jupyter.interactiveWindow.textEditor.executeSelection": true. I believe a notification is supposed to show when first trying to use shift+enter to execute which can be used to set that.

Antyos commented 1 year ago

can you check that you have the setting "jupyter.interactiveWindow.textEditor.executeSelection": true

Nope, but I do now. That seems to fix the issue. Thanks!