微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

创建聊天机器人时出现 sqlalchemy.exc.ArgumentError

如何解决创建聊天机器人时出现 sqlalchemy.exc.ArgumentError

 from chatterbot import chatbot
 bot = chatbot("The Royal Zhao")

给出错误

  File "/Users/michaelchary/Documents/GitHub/yalebot/flaskbot.py",line 8,in <module>
    bot = chatbot("The Royal Zhao")
  File "/usr/local/lib/python3.9/site-packages/chatterbot-1.1.0a7-py3.9.egg/chatterbot/chatterbot.py",line 28,in __init__
  File "/usr/local/lib/python3.9/site-packages/chatterbot-1.1.0a7-py3.9.egg/chatterbot/utils.py",line 33,in initialize_class
  File "/usr/local/lib/python3.9/site-packages/chatterbot-1.1.0a7-py3.9.egg/chatterbot/storage/sql_storage.py",line 46,in __init__
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/dialects/sqlite/base.py",line 2009,in has_table
    self._ensure_has_table_connection(connection)
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/default.py",line 341,in _ensure_has_table_connection
    raise exc.ArgumentError(
sqlalchemy.exc.ArgumentError: The argument passed to Dialect.has_table() should be a <class 'sqlalchemy.engine.base.Connection'>,got <class 'sqlalchemy.engine.base.Engine'>. Additionally,the Dialect.has_table() method is for internal dialect use only; please use ``inspect(some_engine).has_table(<tablename>>)`` for public API use.

由于 PyYAML、Spacy、Python 3.9.1(我的版本)之间不兼容,我通过克隆存储库安装了 chatterbot (v1.1) 和 chatterbot-corpus (v1.2.0)。

我有 sql Alchemcy v1.4.13。

我的操作系统是 10.15.7(Mac、Catalina)。

无论我是否启动了 sql 服务器(通过 brew services start MysqL),错误都不会改变。文本字符串的内容没有影响(例如,空格或下划线无关紧要)。

我无法在线报告此错误。这似乎不是安装 chatterbot 时的常见错误

更新 MongoDatabaseAdapter 没有错误,表明问题在于 sqlchatterbot间的链接

解决方法

我能够通过使用 Python 3.7.3(2019 年 3 月发布)而不是 Python 3.9 解决此问题。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。