Jump to content

Make VS code run .py file in command prompt?

Go to solution Solved by phleexiou,

Actually i figured it out. in launch.json i copied the existing config, and changed  "console": "integratedTerminal" to "console": "externalTerminal".

my new launch.json looks like this:

 

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal"
        },
        {
            "name": "run in cmd?",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "externalTerminal"
        }
        
    ]
}

The in the bottom left next to python version and errors/warnings, click on the run method and change it to the "run in cmd?" one, or whatever you choose to name it.
 
This wont change the play button in the top right, but now when you hit f5, it will run in a discrete window.
 

Hi all. I like using VS code, it looks nice, it's well polished, and it doesn't take 5 minutes to launch. 

But, one thing that I miss from normal VS 2019 is that normal VS opened a discrete command prompt window in which to run python scripts.

 

I liked this a lot, mostly cause it was easy to stick the program and editor on separate screens, but also cause it meant minimal clutter in the window that the program was running. 

 

I setup VS code for python according to the websites instructions, but Code seems to only ever run the program in its built in terminal, which has none of the favorable features I enjoyed about running them in the command prompt window. I'm sure there are justifications for that in other more professional contexts with more complex and rigorous program, but my programs are not professional, complex, or rigorous, so it's kind of annoying. 

 

Is there a way to make VS code run python scripts the same way that VS community does? 

Link to comment
https://linustechtips.com/topic/1256186-make-vs-code-run-py-file-in-command-prompt/
Share on other sites

Link to post
Share on other sites

Actually i figured it out. in launch.json i copied the existing config, and changed  "console": "integratedTerminal" to "console": "externalTerminal".

my new launch.json looks like this:

 

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal"
        },
        {
            "name": "run in cmd?",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "externalTerminal"
        }
        
    ]
}

The in the bottom left next to python version and errors/warnings, click on the run method and change it to the "run in cmd?" one, or whatever you choose to name it.
 
This wont change the play button in the top right, but now when you hit f5, it will run in a discrete window.
 
Edited by phleexiou
clarified the playbutton thing
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×