gpt4 book ai didi

python - AttributeError: 'module' 对象没有属性 'config'

转载 作者:行者123 更新时间:2023-11-28 17:46:00 27 4
gpt4 key购买 nike

我是 Python 的新手,正在尝试我的第一个应用程序。为什么我会收到属性消息:

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 . . .

到目前为止,这是我的部分代码:

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: 一些缩进是关闭的...

最佳答案

我也是新手。我有同样的问题。我删除了目录中的 crud(build 和 dist 文件夹等),然后全部重建。答对了!我怀疑,正如 Alain 所建议的那样,PyCharm 缓存了一些不需要的东西。

关于python - AttributeError: 'module' 对象没有属性 'config',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18111803/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com