Can I redirect stderr when running or debugging python code in VS Code? Sometimes I don't want to see all the messages that imported modules spit out. Very often they aren't helpful. I'd like to be able to send stderr to /dev/null or another file sometimes, but not always. I can run my python program that way directly in the terminal, but I want to do this when debugging so I can see my output without it scrolling quickly by. Thank you.
1 Answer
In the debugger press the configuration file down arrow. It probably says current program. Press add configuration. Then towards the bottom of the json file add this:
"args": ["2>/dev/null"]
Remember to put a comma at the end of the previous line. Then run the debugger.
1 Comment
Maddy Guthridge
Since VS Code doesn't run the command in a shell, this will not work. It will simply be passed to the program you're running as an argument.