Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug with VSCode and pipe command

I am using VScode and I would like to debug a program that is used with a pipe command.

In the console, I run my program with

cat dataset.txt | python my_program.py

How can I configure VSCode to pass the cat command so I can debug the program correctly?

I suspect I need to edit launch.json?

{
    "name": "Python: Current File (Integrated Terminal)",
    "type": "python",
    "request": "launch",
    "program": "${file}",
    "console": "integratedTerminal"
},
like image 808
Michael Avatar asked Feb 28 '26 00:02

Michael


1 Answers

If you change "console" to "externalTerminal", when you run the program an external terminal window will open. This window has stdin connected to the keyboard, so if you type or paste content it will be passed to the program until you send or type ctrl-z. stdout goes to the window. Debugging and breakpoints work as expected.

like image 79
bashley Avatar answered Mar 02 '26 15:03

bashley



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!