我想在Django中使用单独的train.py训练chatterbot,但出现错误
代码:
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
from chatterbot.ext.django_chatterbot import settings
bot = ChatBot(**settings.CHATTERBOT)
trainer =ChatterBotCorpusTrainer(bot)
trainer.train('./training_data/')
错误:
Traceback (most recent call last):
File "train.py", line 3, in
from chatterbot.ext.django_chatterbot import settings
File "C:\Users\nuthalapativ\AppData\Local\Continuum\anaconda3\lib\site-
packages\chatterbot\ext\django_chatterbot\settings.py", line 8, in
CHATTERBOT_SETTINGS = getattr(settings, 'CHATTERBOT', {})
File "C:\Users\nuthalapativ\AppData\Local\Continuum\anaconda3\lib\site-
packages\django\conf_init_.py", line 79, in getattr
self.setup(name)
File "C:\Users\nuthalapativ\AppData\Local\Continuum\anaconda3\lib\site-
packages\django\conf_init.py", line 64, in _setup
% (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting
CHATTERBOT, but settings are not configured. You must either define the
environment variable DJANGO_SETTINGS_MODULE or call settings.configure()
before accessing settings.