pythonpython-3.xpython-clicktui

click TypeError: __init__() missing 1 required positional argument: 'name'


Hi, I have this problem

os : linux mint

Code :

#!/usr/bin/python3
import click

@click.Command()
def main():
    print(f"hello world")
    
if __name__ == "__main__": 
    main()

Output :

Traceback (most recent call last):
  File "/home/vlad/Desktop/0/test.py", line 4, in <module>
    @click.Command()
TypeError: __init__() missing 1 required positional argument: 'name'

Solution

  • You should use @click.command()(with small 'c') instead of @click.Command(). There are two separate objects. name for the first one is optional, but the second one is a class which requires name parameter. Check their signatures.