logging: AttributeError: 'module' object has no attribute 'getLogger'

Frank GOENNINGER dg1sbg at googlemail.com
Mon May 24 06:00:46 EDT 2010


Philip Semanchuk <philip at semanchuk.com> writes:

> On May 23, 2010, at 9:46 AM, Frank GOENNINGER wrote:
>>
>> I double checked and yes, getLogger is there. Why is the interpreter
>> asking for an "attribute" here ? Any hints on what I am doing wrong ?
>
>
> Short answer: Change the name of src/pib/logging.py to something else.

Done.

> Long answer: When Python hits the line "import logging", it first
> looks in the current directory and imports logging.py, which in this
> case is the file it's already executing. It never finds the standard
> library's logging module.
>
> One way you could have figured this out would be to add this as the
> first line of main():
>    print dir(logging)
>
> That would have told you what Python thought the logging module looked
> like, and would have perhaps recognized it as your own.

Thanks - learned a lot from your post.

>
> Cheers
> Philip

Cheers
  Frank



More information about the Python-list mailing list