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

Time:04-29

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

CodePudding user response:

"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.

CodePudding user response:

Yes, it is. Like Tim Roberts's explanation, you can get the executed commands in the terminal, you will find Run Python FIle and Debug Python File will not invoke the arguments you defined in the launch.json except you take F5 or Ctrl F5. They just run the python file.

And of course, you can run the python file in the terminal directly and adds the arguments manually.

  • Related