Run Selected Text in Active Terminal gives IndentationError with IPython
See original GitHub issueEnvironment data
- VS Code version: 1.40.2
- Extension version (available under the Extensions sidebar): 2019.11.50794
- OS and version: macOS Catalina 10.15.1
- Python version (& distribution if applicable, e.g. Anaconda): 3.7.5 Anaconda defaults
- Type of virtual environment used (N/A | venv | virtualenv | conda | …): conda
- Relevant/affected Python packages and their versions: XXX
- Jedi or Language Server? (i.e. what is
"python.jediEnabled"
set to; more info #3977): Language Server
Expected behaviour
Selecting some text and running the command “Terminal: Run Selected Text In Active Terminal” properly pastes the selection to an IPython console.
Actual behaviour
IndentationError is received.
Steps to reproduce:
- Launch IPython in the built-in terminal. Then open some file in the editor; type and select
for x in range(3):
print(x)
break
- Execute the command “Terminal: Run Selected Text in Active Terminal”
The following error is received:
In [1]: for x in range(3):
...: print(x)
...: break
File "<ipython-input-1-6c59f84e067e>", line 3
break
^
IndentationError: unexpected indent
Logs
Output for Python
in the Output
panel (View
→Output
, change the drop-down the upper-right of the Output
panel to Python
)
No output
Output from Console
under the Developer Tools
panel (toggle Developer Tools on under Help
; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging
)
No output
Issue Analytics
- State:
- Created 4 years ago
- Reactions:9
- Comments:29 (10 by maintainers)
Top Results From Across the Web
What should I do with "Unexpected indent" in Python?
The issue I'm describing is caused by the Sublime Text editor. The same issue could be caused by other editors as well. Essentially,...
Read more >How do i resolve the unexpected indent error in python
As the error message indicates, you have an unexpected indent error. This error occurs when a statement is unnecessarily indented or its ...
Read more >Python IndentationError: unexpected indent Solution
The cause of the “IndentationError: unexpected indent” error is indenting your code too far, or using too many tabs and spaces to indent...
Read more >Optimizing Jupyter Notebook: Tips, Tricks, and nbextensions
Ctrl + Enter run selected cells; Alt + Enter run the current cell, insert below; Ctrl + S save and checkpoint. Shortcuts when...
Read more >Plotting and Programming in Python - Our Lessons
Practice closing and restarting the JupyterLab server. Key Points. Python scripts are plain text files. Use the Jupyter Notebook for editing and running...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top 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
Try to toggle ipython’s %autoindent into OFF.
https://ipython.org/ipython-doc/3/interactive/reference.html#autoindent
The above is out of date, but useful. For ipython_config.py creation, refer to the latest ipython documentation link below. https://ipython.readthedocs.io/en/stable/config/intro.html#python-configuration-files
Ah, thanks for the clarification. We’ll look into this further.