This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2014年07月06日 00:30 by inglesp, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Messages (2) | |||
|---|---|---|---|
| msg222386 - (view) | Author: Peter Inglesby (inglesp) * | Date: 2014年07月06日 00:30 | |
A script called token.py that imports anything that ends up importing tokenize, such as logging, triggers the following error when the script is run: $ cat token.py import tokenize $ python3 token.py Traceback (most recent call last): File "token.py", line 1, in <module> import tokenize File "/usr/local/Cellar/python3/3.4.0/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tokenize.py", line 38, in <module> __all__ = token.__all__ + ["COMMENT", "tokenize", "detect_encoding", AttributeError: 'module' object has no attribute '__all__' |
|||
| msg222387 - (view) | Author: Ned Deily (ned.deily) * (Python committer) | Date: 2014年07月06日 00:48 | |
That's because there is also a standard library module named token (https://docs.python.org/3/library/token.html). When you run python, by default the current working directory is inserted at the beginning of sys.path, the list of directories searched for modules. If you have a file there that has the same name as a standard library module, e.g. token.py, it will be found first and, thus, "hide" the standard library module of the same name. Either change the name of your file so it does not conflict or make sure it is in a directory not on sys.path. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:05 | admin | set | github: 66123 |
| 2014年07月06日 00:48:31 | ned.deily | set | status: open -> closed nosy: + ned.deily messages: + msg222387 resolution: not a bug stage: resolved |
| 2014年07月06日 00:30:33 | inglesp | create | |