This seems like a general problem with python-click, however there is no mention of it anywhere on google.
If I try run even the simplest of python click scripts, like the following from realpython
import click
@click.group()
def greet():
pass
@greet.command()
def hello(**kwargs):
pass
@greet.command()
def goodbye(**kwargs):
pass
if __name__ == '__main__':
greet()
The Intellij debugger completely bombs with the error message:
Error: no such option: --multiproc
I have tried this with multiple python-click scripts and debugging never works. Has anyone else noticed this and is there any way around this?
IntelliJ IDEA allows starting the debugger session in several ways. Let's choose one: click in the gutter, and then select the command Debug 'Solver' in the popup menu that opens: The debugger starts, shows the Console tab of the Debug tool window, and lets you enter the desired values:
Debugger makes application debugging much easier. Using debugger, we can stop the execution of program at a certain point, inspect variables, step into function and do many things. IntelliJ provides inbuilt Java debugger. Breakpoint allows stopping program execution at certain point.
The debugger starts, shows the Console tab of the Debug tool window, and lets you enter the desired values: By the way, in the Debug Console, you can enter the Python commands: Then the debugger suspends the program at the first breakpoint. It means that the line with the breakpoint is not yet executed. The line becomes blue:
IntelliJ allows creating breakpoints that pause the execution only if a user-defined condition is satisfied. Here's an example that uses the source code above: Now the debugger will stop on the breakpoint only if the given argument is greater than 3. 7. Object Marks This is the most powerful and the least known IntelliJ feature.
The problem arises when you do not pass any parameters to the click entry-point. In that situation, click asks a platform specific function to get it's args, get_os_args()
which is unrelated to sys.argv.
The result effect is that debugger needed arguments are also passed to the click parser, effectively activating an error in click.
The solution is to explicitely pass sys.argv[1:]
to the click entrypoint which will override the default get_os_args()
behavior:
import sys
if __name__ == '__main__':
greet(sys.argv[1:])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With