chatter bot giving error: AttributeError: module 'time' has no attribute 'clock'

26 Views Asked by At

so i am new to python and am trying to make a chatbot with chatterbot when i run the code i get an error:AttributeError: module 'time' has no attribute 'clock'

from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer

# Create a new chat bot named Charlie
chatbot = ChatBot('Charlie')

trainer = ListTrainer(chatbot)

trainer.train([
    "Hi, can I help you?",
    "Sure, I'd like to book a flight to Iceland.",
    "Your flight has been booked."
])

# Get a response to the input text 'I would like to book a flight.'
response = chatbot.get_response('I would like to book a flight.')

print(response)

this is the error i got.

PS C:\Users\iamno\OneDrive\programs> & C:/Users/iamno/AppData/Local/Programs/Python/Python311/python.exe c:/Users/iamno/OneDrive/programs/jarvis/test.py
Traceback (most recent call last):
  File "c:\Users\iamno\OneDrive\programs\jarvis\test.py", line 5, in <module>
    chatbot = ChatBot('Charlie')
              ^^^^^^^^^^^^^^^^^^
  File "C:\Users\iamno\AppData\Local\Programs\Python\Python311\Lib\site-packages\chatterbot\chatterbot.py", line 34, in __init__
    self.storage = utils.initialize_class(storage_adapter, **kwargs)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^   
  File "C:\Users\iamno\AppData\Local\Programs\Python\Python311\Lib\site-packages\chatterbot\utils.py", line 54, in initialize_class
    return Class(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\iamno\AppData\Local\Programs\Python\Python311\Lib\site-packages\chatterbot\storage\sql_storage.py", line 22, in __init__     
    from sqlalchemy import create_engine
  File "C:\Users\iamno\AppData\Local\Programs\Python\Python311\Lib\site-packages\sqlalchemy\__init__.py", line 8, in <module>
    from . import util as _util  # noqa
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\iamno\AppData\Local\Programs\Python\Python311\Lib\site-packages\sqlalchemy\util\__init__.py", line 14, in <module>
    from ._collections import coerce_generator_arg  # noqa
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\iamno\AppData\Local\Programs\Python\Python311\Lib\site-packages\sqlalchemy\util\_collections.py", line 16, in <module>       
    from .compat import binary_types
  File "C:\Users\iamno\AppData\Local\Programs\Python\Python311\Lib\site-packages\sqlalchemy\util\compat.py", line 264, in <module>
    time_func = time.clock
                ^^^^^^^^^^
AttributeError: module 'time' has no attribute 'clock'

i have no idea on how to fix this as i am new to python.

0

There are 0 best solutions below