Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python聊天机器人未运行_Python_Chatterbot - Fatal编程技术网

Python聊天机器人未运行

Python聊天机器人未运行,python,chatterbot,Python,Chatterbot,我试图尝试此代码显示错误消息,请帮助我 from chatterbot.trainers import ListTrainer from chatterbot import ChatBot bot = ChatBot('Buddy') bot.set_trainer(ListTrainer) conversation = open('chats.txt','r').readlines() bot.train(conversation) while True: message = input(

我试图尝试此代码显示错误消息,请帮助我

from chatterbot.trainers import ListTrainer
from chatterbot import ChatBot

bot = ChatBot('Buddy')
bot.set_trainer(ListTrainer)
conversation = open('chats.txt','r').readlines()
bot.train(conversation)
while True:
 message = input('You:')
 if message.strip() != 'Bye':
  reply = bot.get_response(message)
 print('ChatBot:', reply)
 if message.strip() == 'Bye':
  print('ChatBot:Bye')
  break
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
文件“C:\Program Files\JetBrains\PyCharm Community Edition 2020.3.5\plugins\python ce\helpers\pydev\\u pydev_bundle\pydev_umd.py”,第197行,在运行文件中
pydev_imports.execfile(文件名、全局变量、本地变量)#执行脚本
文件“C:\Program Files\JetBrains\PyCharm Community Edition 2020.3.5\plugins\python ce\helpers\pydev\\u pydev\u imps\\u pydev\u execfile.py”,第18行,在execfile中
exec(编译(内容+“\n”,文件,'exec'),全局,loc)
文件“F:/Work/PythonNLPExample/chatbot.py”,第4行,在
bot=ChatBot('Buddy')
文件“F:\Work\PythonNLPExample\venv\lib\site packages\chatterbot\chatterbot.py”,第34行,在\uuu init中__
self.storage=utils.initialize_类(存储_适配器,**kwargs)
文件“F:\Work\PythonNLPExample\venv\lib\site packages\chatterbot\utils.py”,第54行,在初始化类中
返回类(*args,**kwargs)
文件“F:\Work\PythonNLPExample\venv\lib\site packages\chatterbot\storage\sql\u storage.py”,第46行,在uu init中__
如果不是self.engine.dialogue.has_表(self.engine,'Statement'):
文件“F:\Work\PythonNLPExample\venv\lib\site packages\sqlalchemy\dialogs\sqlite\base.py”,行1999,在has\U表格中
info=self.\u获取\u表格\u pragma(
文件“F:\Work\PythonNLPExample\venv\lib\site packages\sqlalchemy\dialogs\sqlite\base.py”,第2521行,在\u get\u table\u pragma中
cursor=connection.exec\u driver\u sql(语句)
AttributeError:“Engine”对象没有属性“exec\u driver\u sql”

欢迎使用堆栈溢出。请阅读。请永远不要使用单空格缩进。这很难阅读,对于像Python这样的空白非常重要的语言,更重要的是要有清晰的缩进。
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2020.3.5\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_umd.py", line 197, in runfile
    pydev_imports.execfile(filename, global_vars, local_vars)  # execute the script
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2020.3.5\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "F:/Work/PythonNLPExample/chatbot.py", line 4, in <module>
    bot = ChatBot('Buddy')
  File "F:\Work\PythonNLPExample\venv\lib\site-packages\chatterbot\chatterbot.py", line 34, in __init__
    self.storage = utils.initialize_class(storage_adapter, **kwargs)
  File "F:\Work\PythonNLPExample\venv\lib\site-packages\chatterbot\utils.py", line 54, in initialize_class
    return Class(*args, **kwargs)
  File "F:\Work\PythonNLPExample\venv\lib\site-packages\chatterbot\storage\sql_storage.py", line 46, in __init__
    if not self.engine.dialect.has_table(self.engine, 'Statement'):
  File "F:\Work\PythonNLPExample\venv\lib\site-packages\sqlalchemy\dialects\sqlite\base.py", line 1999, in has_table
    info = self._get_table_pragma(
  File "F:\Work\PythonNLPExample\venv\lib\site-packages\sqlalchemy\dialects\sqlite\base.py", line 2521, in _get_table_pragma
    cursor = connection.exec_driver_sql(statement)
AttributeError: 'Engine' object has no attribute 'exec_driver_sql'