Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Different behavior when using Debug/Run button and F5/Ctrl+F5 in Visual Studio Code (Python)

I am trying to pass an argument to a python script and I'm using a standard "Python file" debug configuration with the "launch.json" file for this purpose. I have defined the argument in my debug configuration ( "args": ["car"] )and started to run the script with F5. It is working. The application has access to the passed argument.

However, if i try to CLICK on the "Run Python File" button in the upper right corner of my editor the script crashes because of no argument was passed to it.

Same goes for "Debug Python File"-Button and Ctrl+F5. Ctrl+F5 works, clicking the button does not.

What is the issue here?

The code I am trying to run with a passed argument:

https://github.com/RGGH/ebay_api_postgres/blob/main/ebay_21.py

like image 637
ToBeDefined Avatar asked May 14 '26 12:05

ToBeDefined


1 Answers

"Run Python FIle" and "Debug Python File" don't run the "project", so they don't grab the argument from the project configuration. Use F5 and Ctrl-F5, or run in the terminal.

like image 161
Tim Roberts Avatar answered May 16 '26 00:05

Tim Roberts



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!