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

Time:12-06

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'

CodePudding user response:

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.

  • Related