Forums

Problem importing logging module

Hi,

is this concerning the "logging" module in python3.4?

When using this module in console (on python3.4), it works fine (I copy/pasted between console and script).

When creating a script, I receive the following error:

    logging.basicConfig(level=logging.DEBUG, format=' %(asctime)s -%(levelname)s - %(message)s')
AttributeError: 'module' object has no attribute 'basicConfig'

The first 3 lines of the script are:

import logging
logging.basicConfig(level=logging.DEBUG, format=' %(asctime)s - %(levelname)s- %(message)s')
logging.debug('Start of program')

or do I need to create a seperate thread for this one.

[admin] Moved from here.

That sounds like you have another module called logging somewhere on your Python system path -- perhaps one of the directories or files in your own code is called logging or logging.py?

Hi Giles

thank you for your answer. the file itself was called logging.py, since it was an exercise on logging. renamed the file and it worked.

Thanks a lot for your help!

Ah, that would explain it :-) Glad that sorted it out!

Hi! I am having the same issue, but I do not have any additional module (or file that I wrote) named logging, as far as I can see. Is there any way to make sure about this?

To be exact, the error that I get is slightly different:

AttributeError: 'Logger' object has no attribute 'basicConfig'

Nevermind, that was me making a mistake in the code and using basicConfig method on the logger object instead of the module itself lol

Glad to hear that you found it!