python - Python 聊天机器人未运行
问题描述
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
我尝试尝试显示错误消息的代码,请帮助我
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'
解决方案
推荐阅读
- php - 使用 Laravel Eloquent 自动设置属性
- arrays - 如何访问作为属性从导入的数组中列出的视频 src,该数组使用 map() 在 React JS 的轮播中显示视频?
- h2o - 获取水。H2O 部分图的异常
- c# - C#尝试从方法内部创建一个带有可选参数的全局对象实例
- python - matplotlib FuncAnimation - 确保图例和情节线具有相同的颜色?
- javascript - 如何使用 Javascript 将任何图像格式转换为 .ico 格式
- git - git shallow fetch 不显示分支
- javascript - 将香草js转换为jquery
- python - 子集列表并保留具有空白缺失值的原始长度
- thymeleaf - Thymeleaf 中的切换形式