Comments (9)
Obvious error, my file was called click.py, so when using import click
it was importing the file, not the Click library
from click.
Don't name your file click.py
. This is a Python limitation.
from click.
i also named mine "click.py", thanks for the hint @FredoJones .
only then did the strangeness disappear
from click.
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.
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.
That's just an old version of click.
from 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'
from click.
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.
Don't name your file click.py is correct answer.
from click.
Related Issues (20)
- Docs wrongly links PRs and Issues to flask
- The type hint for the filename parameter to open_file is incomplete HOT 1
- Missing reset on should_strip_ansi causing cascading issues during other tests
- Custom type called twice with prompt HOT 2
- Display exception notes when raising `ClickException` HOT 2
- Optionally expand global variables in parameters? HOT 2
- click.Path(resolve_path=True) crash on non-Path HOT 2
- partially initialized module 'click' has no attribute 'command' (most likely due to a circular import)
- Modifying default_map in callback behaves differently between click 7.1.2 and 8.0.0
- `flag_value` is not taken into account with `envvar`
- Click does not detect duplicate option flags HOT 2
- Cursor Keys show escape characters like ^[[D when inputting missing options HOT 2
- get_parameter_source does not work with invoke or forward
- calling with no args should print help HOT 1
- List of commands when creating a concrete class from `click.MultiCommand` does not display any commands in the CLI. HOT 1
- document how to create a standalone application HOT 2
- CliRunner.invoke doesn't capture stdout from logging HOT 1
- Way to render CLI usage examples in docstrings HOT 3
- Provide suggestions for misspelled subcommands
- double-dash handling does not support wrapper scripts. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from click.