skip to Main Content

so I’m running python on studio visual code with the extension code runner. enter image description here

As you can see I have a file named fart.py, I’m running the output to the terminal because I’m handling user input. But whenever I run the code it doesn’t refresh so I have everything from previous runs, and it gives me the path information ( PS C:UsersPlutoOneDriveDesktoppython stuff> & C:/Users/Pluto/AppData/Local/Programs/Python/Python311/python.exe "c:/Users/Pluto/OneDrive/Desktop/python stuff/fart.py" ).

I don’t want to see the paths and I would like to have the terminal refresh every time I run some code.
I’ve looked around online, looked through the settings and I can’t really find anything.
Thanks for the help.

2

Answers


  1. How can Code Runner run the code? It runs commands automatically, therefore we don’t need to do that manually, but as you see, commands are still necessary. The only difference is that the extension itself runs the commands.

    Unfortunately, it’s not supported to configure what you need in Code Runner… So think just like you do it manually? For example, you can execute Terminal: Clear in Command Palette to "refresh the terminal".

    I hope that may help you.

    p.s. The comment from Zac Anger gives a great solution by code.
    Just edit code-runner.executorMap setting accordingly and everything can go well.

    Login or Signup to reply.
  2. You can add the following code to your settings.json:

      "code-runner.runInTerminal": false,
      "code-runner.clearPreviousOutput": true,
      "code-runner.showExecutionMessage": false,
    

    In this way, the path will not be displayed each time you run file, and the last run result will be cleared automatically each time you run if you use code-runner extension.

    Example:

    test.py:

    print("hello")
    

    Output:

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search