Support IPython for Shift+Enter (execute line in terminal)
See original GitHub issueDiscussed in https://github.com/microsoft/vscode-python/discussions/16744
<div type='discussions-op-text'>Originally posted by sergeyf July 20, 2021
Environment data
- VS Code version: 1.58.2
- OS and version: Windows_NT x64 10.0.19043
- Python version (& distribution if applicable, e.g. Anaconda): 3.9,1
- Type of virtual environment used (N/A | venv | virtualenv | conda | …): conda
- Value of the
python.languageServer
setting: pylance-2021.7.4
Expected behaviour
Pressing Shift + Enter copies code to the terminal and executes it
Actual behaviour
Pressing Shift + Enter copies code to the terminal but it doesn’t execute
Steps to reproduce:
</div>EDIT: https://github.com/microsoft/vscode-python/issues/18177 could resolve this.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:25
- Comments:12 (2 by maintainers)
Top Results From Across the Web
How can i force SHIFT+ENTER to run selection and execute it ...
I have added the setting below in vscode to launch ipython when i used shift+enter to run selection. "python.terminal.launchArgs": [ "-c" ...
Read more >VS Code: Shift+Enter does not send code to Python Interactive
Shift + Enter is registered as a keyboard shortcut for both sending code to Terminal and for sending it to Python Interactive. I...
Read more >The IPython Notebook — IPython 3.2.1 documentation
The notebook consists of a sequence of cells. A cell is a multi-line text input field, and its contents can be executed by...
Read more >VSCode Python Data Science Setup, Part 9: Shift+Enter to ...
... and has data science support for #Python Scripting and Jupyter Notebooks. This is a multi-part YouTube Series that comes from my Python ......
Read more >3.5. Python types assignment - Jean Mark Gawron
If Python does not seem to be responding to you when you execute commands that ... Then, in the same terminal window you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have this problem off and on as well. You can get around it if you have the multi-command extension by adding the following to your keybindings.json:
I stole the solution from here with some slight modifications. Mostly adding an interval as the commands were happening too quickly sometimes.
This issue is funny, because sometimes I get the desired behavior already, and sometimes I don’t, depending on my conda environment.
Environment A from CONDA-FORGE: This environment gives me the normal behavior where code is copied and properly executed: conda create --name py37A --channel conda-forge python=3.7 ipython ipykernel
So if I highlight the following and do shift+enter:
The IPython console looks like this:
Environment B from DEFAULTS (Anaconda): This environment gives me the bug behavior where code is copied but not executed: conda create --name py37B --channel defaults python=3.7 ipython ipykernel
So if I highlight the following and do shift+enter:
The IPython console looks like this:
I’m on Windows 10, and the latest install of VSCode, but no insiders channel, or similar.
I don’t know if the difference in behavior is from the
conda-forge
channel having slightly newer packages, or from some deeper differences. Updating theprompt_toolkit
package in Environment B from the conda-forge channel (which updates several dependencies) is enough to allow that environment to have the “no bug expected behavior”.