Giter Site home page Giter Site logo

Comments (9)

joebentley avatar joebentley commented on August 25, 2024 38

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

from click.

mitsuhiko avatar mitsuhiko commented on August 25, 2024 8

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

from click.

fninja avatar fninja commented on August 25, 2024 6

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

from click.

mitsuhiko avatar mitsuhiko commented on August 25, 2024

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

from click.

juriansluiman avatar juriansluiman commented on August 25, 2024

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.

from click.

mitsuhiko avatar mitsuhiko commented on August 25, 2024

That's just an old version of click.

from click.

joebentley avatar joebentley commented on August 25, 2024

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'

from click.

styk-tv avatar styk-tv commented on August 25, 2024

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

from click.

HayTran avatar HayTran commented on August 25, 2024

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

from click.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.