I downloaded master branch few min agao.And installed it on windows 7 with python 2.7.5.
While import click it give me error
AttributeError: 'module' object has no attribute 'command'
Closed for the time being. If you can show me a traceback I will repoen it. At the moment closed for "works for me".
I am having the same problem on an Ubuntu 14.04 with python 2.7. Click installed via pip. Note I am very new to python, so I might have done something wrong. However, I copy/pasted the example code from the clip homepage:
jurian@kaia:~/test$ cat __init__.py
import click
@click.command()
@click.option('--count', default=1, help='number of greetings')
@click.option('--name', prompt='Your name',
help='the person to greet', required=True)
def hello(count, name):
for x in range(count):
click.echo('Hello %s!' % name)
if __name__ == '__main__':
hello()
jurian@kaia:~/test$ python __init__.py --name=Jurian
Traceback (most recent call last):
File "__init__.py", line 12, in <module>
hello()
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 320, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 304, in main
self.invoke(ctx)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 276, in invoke
ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 169, in invoke
return callback(*args, **kwargs)
File "__init__.py", line 9, in hello
click.echo('Hello %s!' % name)
AttributeError: 'module' object has no attribute 'echo'
Here it's about the "echo" and not "command", but the type of error should be the same I guess. If you need more info, I can show some more.
That's just an old version of click.
I'm getting the same issue on the latest version of click
Traceback (most recent call last):
File "click.py", line 1, in <module>
import click
File "/Users/joe/src/python/click/click.py", line 3, in <module>
@click.group()
AttributeError: 'module' object has no attribute 'group'
Obvious error, my file was called click.py, so when using import click it was importing the file, not the Click library
i also named mine "click.py", thanks for the hint @fredojones .
:warning: in my case a file called click.pyc was created in my pwd, which i needed to delete.
only then did the strangeness disappear
Resurfaced Python 2.7.10 on Mac El Capitan
Pip 8.1.2
Click: 6.6
Homepage http://github.com/mitsuhiko/click
License: UNKNOWN
`
Python 2.7.10 (default, Jul 13 2015, 12:05:58)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
import click
Traceback (most recent call last):
File "", line 1, in
File "click.py", line 3, in
@click.command()
AttributeError: 'module' object has no attribute 'command'
`
Don't name your file click.py. This is a Python limitation.
Don't name your file click.py is correct answer.
Most helpful comment
Obvious error, my file was called click.py, so when using
import clickit was importing the file, not the Click library