You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow "Run Python File in Terminal" button to be configurable #11812
This could be done by linking it to "Run Without Debugging" if we have an easy set up experience for running scripts. Or simply by allowing arguments to be passed to python (e.g. -i) or to the file.
I agree here, unless I'm missing something apparently there isn't any way to run a script with arguments through this button/command. One is forced to use the Debug screen launchers which is substantially less convenient.
I agree here, unless I'm missing something apparently there isn't any way to run a script with arguments through this button/command. One is forced to use the Debug screen launchers which is substantially less convenient.
Another good option would be to add the ability to run currently open file as a module. This is already referenced by #10130 in a slightly different way. Currently there is only a way to set a specific module to be ran.
There is a workaround that works for files in the project root directory:
I think there should be an option to run the currently open file as a module and also set that to be the default behaviour for the "Run Python File" button so that it could be used without starting the debugger.
Reacted by Simon Friedberger, Apromixately, Tom, mattviguier and ManiMatter
I agree with Anton Vučinić (@AntonVucinic) and #10130 running files as a module would be useful. When there is a bit of folder hierarchy, the only way to import something is to use modules. This could also be solved with some search/replace in the variables.
To give a bash example:
folder='foo/bar/baz'
echo ${folder//\//.}
gives foo.bar.baz which is pretty much what is needed here. Then this could be solved using:
Activity
Inetov commentedon Oct 16, 2020
yes, at the moment this is a completely useless button.
we have a button close at hand, but to use launch.json we need to go to the menu ...
gandhis1 commentedon May 12, 2022
I agree here, unless I'm missing something apparently there isn't any way to run a script with arguments through this button/command. One is forced to use the Debug screen launchers which is substantially less convenient.
diogo-rossi commentedon Sep 11, 2022
Siddhartha Gandhi (@gandhis1), if you think it will be good, please, up vote this
diogo-rossi commentedon Sep 12, 2022
Luciana Abud (@luabud), I think we already can pass arguments to python with the setting
"python.terminal.launchArgs".I've opened this issue to request the same for the script file.
luabud commentedon Sep 14, 2022
Yes, good point! And perhaps you meant to reference #19810?
diogo-rossi commentedon Sep 14, 2022
Yeah, my bad. I updated the link now.
AntonVucinic commentedon Sep 19, 2022
Another good option would be to add the ability to run currently open file as a module. This is already referenced by #10130 in a slightly different way. Currently there is only a way to set a specific module to be ran.
There is a workaround that works for files in the project root directory:
I think there should be an option to run the currently open file as a module and also set that to be the default behaviour for the "Run Python File" button so that it could be used without starting the debugger.
starball5 commentedon Jun 21, 2023
Possibly related on Stack Overflow: How can I configure the "Run" button next to the editor tabs in VS Code for Python files?
Apromixately commentedon Nov 23, 2023
I agree with Anton Vučinić (@AntonVucinic) and #10130 running files as a module would be useful. When there is a bit of folder hierarchy, the only way to import something is to use modules. This could also be solved with some search/replace in the variables.
To give a bash example:
gives
foo.bar.bazwhich is pretty much what is needed here. Then this could be solved using:Apologies if this seems like hijacking this issue but #10130 is closed.
Apromixately commentedon Nov 23, 2023
Actually, there might be an easier way to solve this. Afaict from https://code.visualstudio.com/docs/editor/variables-reference#_command-variables, if this extension would define a
getModulefunction we could use${command:getModule}.starball5 commentedon Dec 7, 2023
Related: https://code.visualstudio.com/updates/v1_85#_configurable-debugging-option-under-the-run-button-menu