-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python: unable to run current line in Python file in Python terminal #22552
Comments
Can you try updating the Python extension version to the latest and try to shift+enter again? |
Currently using v2023.22.0 and problem still occurs. |
Try adding following in your settings.json
and then There should be warning message if there are invalid or deprecated Python code in your currently opened file that looks like: Also FYI: We don't officially support 3.7 as of #21962 |
Well still not working and I don't get the popup message. You really think this could be caused by an unsupported Python version? I'll update it and come back with more info. Thanks! Edit: Tried with 3.12 and same problem. |
@mchibok can you share the code content in the Python file and the specific line you shift+enter at? |
@anthonykim1, I don't really need to send the content of the Python file, any line from a .py file I get the problem. Cursor is at start of line 8, Selecting the line 8 and doint ctrl + shift sends the code: Selecting part of the line 8 sends selected code (which I believe is expected behaviour): Thanks! |
The reason why I am asking you to provide whole content of the file is with the new smart send feature, pressing shift enter on any line of the file that contains deprecated or invalid code makes the smart send feature to fail to work. This is because Python AST, which is behind the scene fails to parse Python file that contains deprecated or invalid code. Can you try to make a new file with something like and YES you are very correct on expected behavior of specific highlight/selection only sending that code. |
Brand new file and I'm using Python in a conda environment. I had not mentionned this previously since shift+enter when selected did work. I just tried with 2 different environments and I can reproduce problem in both. Thanks for your help! |
While disabling REPL Smart Send for user and workspace settings, I also disabled it for my folder settings (\actifs.vscode\settings.json). When folder settings REPL is activated:
with the last line being sent when shift+enter on current line (does not send the actuel command). When REPL disabled in folder settings, shift+enter works for current line:
Again, last lines sent when shift+enter on current line. So basically, I can just disable REPL in folder settings and everything seems to be working! |
Type: Bug
Behaviour
Expected vs. Actual
Usually, running execSelectionInTerminal (either through the command palette with "Run the current line or selection in Python terminal" or my custom shortcut shift+enter) runs either the line where my cursor is in the python file or the selected line(s).
Now for some reason it does not work for the current line, only works when there is a selection.
Diagnostic data
python.languageServer
setting: DefaultOutput for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)User Settings
VS Code version: Code 1.84.2 (1a5daa3a0231a0fbba4f14db7ec463cf99d7768e, 2023-11-09T10:51:52.184Z)
OS version: Windows_NT x64 10.0.19045
Modes:
System Info
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Extensions (14)
A/B Experiments
The text was updated successfully, but these errors were encountered: