Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: 'module' object has no attribute 'config'

I'm new to Python and am trying my first applications. Why am I getting the Attribute message:

Traceback (most recent call last): File "C:\Users\myname\documents\visual studio 2010\Projects\PythonApplication 1\PythonApplication1\RunSikuliOnVM.py", line 97, in logging.config.dictConfig(LOG_DICT_CONFIG_OnVM) AttributeError: 'module' object has no attribute 'config' Press any key to continue . . .

Here is a portion of my code so far:

import os
import sys
import subprocess
import fnmatch
import datetime
import logging
import logging.handlers
import logging.config

"""===Global Variables==="""

LOGFILE = r"V:/RunTests.log"
LOGDETAILS= r"V:/SikuliScriptDetails.log"
FAILEDTESTS = r"V:/FailedTests.txt"

"""Logging configuration"""
#   Dictionary configuration for logging within RunSikuliOnVM.py
LOG_DICT_CONFIG_OnVM = {
    'version': 1,              
    'disable_existing_loggers': False,
    'formatters': {
        'verbose': {
        'format': '%(levelname)-8s %(asctime)s %(module)s %(process)d %(thread)d %(message)s',
        'datefmt': '%a, %d %b %Y %H:%M:%S'

    },
    'standard': {
        'format': '%(asctime)s [%(levelname)s] %(name)s: %(message)s',
        'datefmt': '%a, %d %b %Y %H:%M:%S'

    },
    'simple': {
        'format': '%(asctime)s %(levelname)-8s %(message)s',
        'datefmt': '%a, %d %b %Y %H:%M:%S'
    }
},
'handlers': {
    'console': {
        'level':'DEBUG',    
        'class':'logging.StreamHandler',
        'formatter': 'simple'
    },
    'RunTests_Handler': {
        'class': 'logging.handlers.TimedRotatingFileHandler',
        'level': 'DEBUG',
        'formatter': 'simple',
        'filename': LOGFILE,
        'when':'D',
        'interval': 7, 
        'backupCount':1, 
        'encoding': None, 
        'delay': False, 
        'utc': False,
    },
    'SikuliScriptDetails_Handler': {
        'class': 'logging.handlers.TimedRotatingFileHandler',
        'level': 'DEBUG',
        'formatter': 'verbose',
        'filename':LOGDETAILS,
        'when':'D',
        'interval': 7, 
        'backupCount':2, 
        'encoding': None, 
        'delay': False, 
        'utc': False,
    },
    'FailedTests_Handler': {
        'class': 'logging.handlers.TimedRotatingFileHandler',
        'level': 'DEBUG',
        'formatter': 'standard',
        'filename':FAILEDTESTS,
        'when':'D',
        'interval': 7, 
        'backupCount':2, 
        'encoding': None, 
        'delay': False, 
        'utc': False,
    }
},
'loggers': {
    'RunTests_Logger': {                  
        'handlers': ['RunTests_Handler'],        
        'level': 'DEBUG',  
        'propagate': False  
    },
    'SikuliScriptDetails_Logger': { 
        'handlers': ['SikuliScriptDetails_Handler'],
        'level': 'DEBUG',  
        'propagate': False 
    },
    'FailedTests_Logger': {
        'handlers': ['FailedTests_Handler'],
        'level': 'DEBUG',
        'propagate': False
    }
}
}

logging.config.dictConfig(LOG_DICT_CONFIG_OnVM)

logfilelogger = logging.getLogger('RunTests_Logger')
logdetailslogger = logging.getLogger('SikuliScriptDetails_Logger')
failedtestslogger = logging.getLogger('FailedTests_Logger')

PS: Some of the indentation is off...

like image 559
Alain Avatar asked Feb 05 '26 20:02

Alain


1 Answers

I'm also a newbie. I had the same problem. I deleted the crud in my directory (build and dist folders etc), then rebuilt it all. Bingo! I suspect that, as Alain suggested, PyCharm has cached something undesirable.

like image 199
Return_Of_The_Archons Avatar answered Feb 08 '26 15:02

Return_Of_The_Archons