ChatterBot icon indicating copy to clipboard operation
ChatterBot copied to clipboard

Problem with time.clock in compat.py

Open leedh0209 opened this issue 4 years ago • 2 comments

I tested the sample code in your documentation "Quick Start Guide". But I faced error like this.

Traceback (most recent call last): File "D:/2021 2학기/인공지능/Team project/1.py", line 2, in chatbot = ChatBot("Ron Obvious") File "C:\Users\이동훈\AppData\Local\Programs\Python\Python39\lib\site-packages\chatterbot\chatterbot.py", line 34, in init self.storage = utils.initialize_class(storage_adapter, **kwargs) File "C:\Users\이동훈\AppData\Local\Programs\Python\Python39\lib\site-packages\chatterbot\utils.py", line 54, in initialize_class return Class(*args, **kwargs) File "C:\Users\이동훈\AppData\Local\Programs\Python\Python39\lib\site-packages\chatterbot\storage\sql_storage.py", line 22, in init from sqlalchemy import create_engine File "C:\Users\이동훈\AppData\Local\Programs\Python\Python39\lib\site-packages\sqlalchemy_init_.py", line 8, in from . import util as util # noqa File "C:\Users\이동훈\AppData\Local\Programs\Python\Python39\lib\site-packages\sqlalchemy\util_init.py", line 14, in from ._collections import coerce_generator_arg # noqa File "C:\Users\이동훈\AppData\Local\Programs\Python\Python39\lib\site-packages\sqlalchemy\util_collections.py", line 16, in from .compat import binary_types File "C:\Users\이동훈\AppData\Local\Programs\Python\Python39\lib\site-packages\sqlalchemy\util\compat.py", line 264, in time_func = time.clock AttributeError: module 'time' has no attribute 'clock'

So, I changed 'time.clock' into 'time.time' in compat.py Ln 264. And then it worked well. I'm using Windows10 64bit OS, x64 processor. And python version is 3.9.4.

leedh0209 avatar Nov 10 '21 07:11 leedh0209

The function time.clock() has been removed, after having been deprecated since Python 3.3

rafaelmaframg avatar Nov 17 '21 14:11 rafaelmaframg

I found a way to resolve this. First head to C:\Users\이동훈\AppData\Local\Programs\Python\Python39\lib\site-packages\sqlalchemy\util\compat.py

Then change lines 263-266: if win32 or jython: time_func = time.clock else: time_func = time.time

To this: try: time_func = time.clock except: time_func = time.time

sukadateam avatar Dec 01 '21 17:12 sukadateam