Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'module' object has no attribute 'command' #4

Closed
codepad opened this issue Apr 24, 2014 · 9 comments
Closed

AttributeError: 'module' object has no attribute 'command' #4

codepad opened this issue Apr 24, 2014 · 9 comments

Comments

@codepad
Copy link

codepad commented Apr 24, 2014

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'

@mitsuhiko
Copy link
Contributor

Closed for the time being. If you can show me a traceback I will repoen it. At the moment closed for "works for me".

@juriansluiman
Copy link

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.

@mitsuhiko
Copy link
Contributor

That's just an old version of click.

@joebentley
Copy link

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'

@joebentley
Copy link

Obvious error, my file was called click.py, so when using import click it was importing the file, not the Click library

@fninja
Copy link

fninja commented Oct 7, 2015

i also named mine "click.py", thanks for the hint @FredoJones .
⚠️ in my case a file called click.pyc was created in my pwd, which i needed to delete.
only then did the strangeness disappear

@styk-tv
Copy link

styk-tv commented Jan 3, 2017

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'
`

@mitsuhiko
Copy link
Contributor

Don't name your file click.py. This is a Python limitation.

@mitsuhiko mitsuhiko reopened this Jan 3, 2017
@HayTran
Copy link

HayTran commented Dec 27, 2017

Don't name your file click.py is correct answer.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants