简体   繁体   中英

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'

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM