簡體   English   中英

運行簡單代碼時 ChatterBot 庫出錯

[英]Error with ChatterBot library when running simple code

我無法簡單地從 lib ChatterBot 運行這個簡單的代碼:

from chatterbot import ChatBot 
from chatterbot.trainers import ListTrainer 
from chatterbot.trainers import ListTrainer 
  
bot = ChatBot('Bot') 
  
trainer = ListTrainer(bot) 
  
trainer.train([ 
    'Hi', 
    'Hello', 
    'I need roadmap for Competitive Programming', 
    'Just create an account on GFG and start', 
    'I have a query.', 
    'Please elaborate, your concern', 
    'How long it will take to become expert in Coding ?', 
    'It usually depends on the amount of practice.', 
    'Ok Thanks', 
    'No Problem! Have a Good Day!'
]) 
  
while True: 
    request=input('you :') 
    if request == 'OK' or request == 'ok': 
        print('Bot: bye') 
        break
    else: 
        response=bot.get_response(request) 
        print('Bot:', response) 

提出的問題如下:

    Traceback (most recent call last):
  File "C:\Users\User\Desktop\TESTE AI.py", line 5, in <module>
    bot = ChatBot('Bot')
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\chatterbot\chatterbot.py", line 41, in __init__
    self.storage = utils.initialize_class(storage_adapter, **kwargs)
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\chatterbot\utils.py", line 54, in initialize_class
    return Class(*args, **kwargs)
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\chatterbot\storage\sql_storage.py", line 46, in __init__
    if not self.engine.dialect.has_table(self.engine, 'Statement'):
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\sqlalchemy\dialects\sqlite\base.py", line 2016, in has_table
    self._ensure_has_table_connection(connection)
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\sqlalchemy\engine\default.py", line 342, 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.

信息:

  • 聊天機器人==1.0.0 && 1.0.4 && 1.0.5 && 1.1.0
  • 蟒蛇==3.8.10

我現在謝謝你!!

嘗試將 sqlalchemy 升級到當前版本 (1.4.41):

pip install sqlalchemy --upgrade

它可能是重復的:

類似的帖子在這里

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM