如何摆脱 ConfigParser is not defined 错误?

How to get rid of ConfigParser is not defined error?

下面是我的 settings.py 文件。

import configparser
import os
import sys

import djcelery
import redis
import raven

djcelery.setup_loader()

# this should disable some of the warnings sam
# import urllib3
# urllib3.disable_warnings()

#####################################################

# this has been moved to config/tools.conf


#####################################################
PROJECT_PATH = os.path.split(os.path.abspath(os.path.join(__file__, os.pardir)))[0]
config = ConfigParser.ConfigParser()

ctx = ConfigParser.RawConfigParser()
ctx.read('%s/config/tools.conf' % PROJECT_PATH)

当我 运行 命令 python manage.py celeryd 时,我一直收到以下错误,有人能指出这里出了什么问题吗?

File "/opt/tools/core/settings.py", line 22, in <module>
    config = ConfigParser.ConfigParser()
NameError: name 'ConfigParser' is not defined

请进行以下更改以使代码正常工作。

改变

config = ConfigParser.ConfigParser()

config = configparser.ConfigParser()

然后改

ctx = ConfigParser.RawConfigParser()

ctx = configparser.RawConfigParser()