Error using a bot in python

Asked

Viewed 29 times

0

Whenever I run the following code (using python)

from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer

bot = ChatBot('bot1')
bot = ChatBot(
    'bot1',
    storage_adapter='chatterbot.storage.SQLStorageAdapter',
    database_uri='sqlite:///database.sqlite3'
)

conversa = ListTrainer(bot)
conversa.train([
    'Olá',
    'Oi',
    'Qual o seu nome?',
    'bot1',
    'Prazer em te conhecer',
    'Igualmente',
])
while True:
    try:
        resposta = bot.get_response(input("Usuário: "))
        if float(resposta.confidence) > 0.5:
            print("bot1: ", resposta)
        else:
            print("Eu não entendi :(")
    except(KeyboardInterrupt, EOFError, SystemExit):
        break

I get this error message


Traceback (most recent call last):
  File "C:\Users\Gabriel\PycharmProjects\guppe\bot1\python3 bot.py", line 4, in <module>
    bot = ChatBot('bot1')
  File "C:\Users\Gabriel\AppData\Local\Programs\Python\Python39\lib\site-packages\chatterbot-1.1.0-py3.9.egg\chatterbot\chatterbot.py", line 28, in __init__
  File "C:\Users\Gabriel\AppData\Local\Programs\Python\Python39\lib\site-packages\chatterbot-1.1.0-py3.9.egg\chatterbot\utils.py", line 33, in initialize_class
  File "C:\Users\Gabriel\AppData\Local\Programs\Python\Python39\lib\site-packages\chatterbot-1.1.0-py3.9.egg\chatterbot\storage\sql_storage.py", line 22, in __init__
  File "C:\Users\Gabriel\AppData\Local\Programs\Python\Python39\lib\site-packages\sqlalchemy\__init__.py", line 8, in <module>
    from . import util as _util  # noqa
  File "C:\Users\Gabriel\AppData\Local\Programs\Python\Python39\lib\site-packages\sqlalchemy\util\__init__.py", line 14, in <module>
    from ._collections import coerce_generator_arg  # noqa
  File "C:\Users\Gabriel\AppData\Local\Programs\Python\Python39\lib\site-packages\sqlalchemy\util\_collections.py", line 16, in <module>
    from .compat import binary_types
  File "C:\Users\Gabriel\AppData\Local\Programs\Python\Python39\lib\site-packages\sqlalchemy\util\compat.py", line 264, in <module>
    time_func = time.clock
AttributeError: module 'time' has no attribute 'clock'

Process finished with exit code 1

Does anyone know what it can be?

1 answer

1

By your error log, you are using Python 3.9.

Looking at the documentation of Python 3.8, the function time.clock() was discontinued in version 3.3 and removed in version 3.8, which is probably the source of your error.

As you do not have easy access to editing the library that uses this method (so you could use the methods time.perf_counter() or time.process_time() as substitutes for versions of Python 3.8 or more), I believe the easiest solution would be for you to make a downgrade from your version of Python to any earlier than version 3.8.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.