AttributeError: module 'time' has no attribute 'clock'
See original GitHub issueWhen trying to make an instance of the ChatBot class and the try to get the response from the user’s input, I get an error that the time module doesn’t have a ‘clock’ attribute. Here’s my code:
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
chatbot = ChatBot('Sofia')
trainer = ListTrainer(chatbot=chatbot)
trainer.train(
"Hey",
"Hi, how can I help you?",
"Can you show me the weather please?",
"Sure! Coming right up.",
"Thanks",
"You're welcome!"
)
while True:
user_input = input('You: ')
response = chatbot.get_response(user_input)
print(f"Sofia: {response}")
And this is the full traceback:
Traceback (most recent call last):
File "C:\Users\Eric\Desktop\bot\ai.py", line 5, in <module>
chatbot = ChatBot('Sofia')
File "C:\Users\Eric\AppData\Local\Programs\Python\Python38\lib\site-packages\chatterbot\chatterbot.py", line 34, in __init__
self.storage = utils.initialize_class(storage_adapter, **kwargs)
File "C:\Users\Eric\AppData\Local\Programs\Python\Python38\lib\site-packages\chatterbot\utils.py", line 47, in initialize_class
return Class(*args, **kwargs)
File "C:\Users\Eric\AppData\Local\Programs\Python\Python38\lib\site-packages\chatterbot\storage\sql_storage.py", line 22, in __init__
from sqlalchemy import create_engine
File "C:\Users\Eric\AppData\Local\Programs\Python\Python38\lib\site-packages\sqlalchemy\__init__.py", line 8, in <module>
from . import util as _util # noqa
File "C:\Users\Eric\AppData\Local\Programs\Python\Python38\lib\site-packages\sqlalchemy\util\__init__.py", line 14, in <module>
from ._collections import coerce_generator_arg # noqa
File "C:\Users\Eric\AppData\Local\Programs\Python\Python38\lib\site-packages\sqlalchemy\util\_collections.py", line 16, in <module>
from .compat import binary_types
File "C:\Users\Eric\AppData\Local\Programs\Python\Python38\lib\site-packages\sqlalchemy\util\compat.py", line 264, in <module>
time_func = time.clock
AttributeError: module 'time' has no attribute 'clock'
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
AttributeError: module 'time' has no attribute 'clock' in Python 3.8
Go to your error last line and go to that directory and open that particular file. search time.clock using ctrl+f and replace it...
Read more >AttributeError module 'time' has no attribute 'clock' | bobbyhadz
The Python "AttributeError module 'time' has no attribute 'clock'" occurs because since Python v3.8, the clock() function has been removed.
Read more >Attributeerror: module time has no attribute clock ( Solved )
Attributeerror : module time has no attribute clock occurs because of time.clock function is now deprecated in python 3.8 or later versions.
Read more >AttributeError module 'time' has no attribute 'clock' - Python GUIs
AttributeError module 'time' has no attribute 'clock ' Using PyQtGraph with Python 3.8 ... PyQtGraph is a library for creating plots in PyQt ......
Read more >AttributeError: module 'time' has no attribute 'clock' - Odoo
The function time.clock() has been removed, after having been deprecated since Python 3.3: use time.perf_counter() or ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
A common error SOLVED If you are using Python 3.8 , download the previous version
Go to CMD pip install chatterbot==1.0.4
This will work and everything is installed
You will probably get an error after some time, where it says File "C:\Python38\lib\site-packages\sqlalchemy\util\compat.py
", line 264, in <module> time_func = time.clock AttributeError: module ‘time’ has no attribute ‘clock’
This is because time.clock() function was removed in Py 3.8.
Go to the search bar and then paste the location given right above the last line of error
It will look something like this : C:\Python38\lib\site-packages\sqlalchemy\util\compat.py
Open file with IDLE or whatever editor you have
Then , go to line 264 in that . It would be written time_func = time.clock()
Instead of this change, it to time.perf_counter()
Save the file and now run it. It will work
Chatterbot version chatterbot==1.0.7 and chatterbot==1.0.8 are not available not to install and version 1.10 is failing while installation. Error:`Installing build dependencies … error ERROR: Command errored out with exit status 1: command: ‘c:\users\aditya sharma\appdata\local\programs\python\python38-32\python.exe’ ‘c:\users\aditya sharma\appdata\local\programs\python\python38-32\lib\site-packages\pip’ install --ignore-installed --no-user --prefix ‘C:\Users\Aditya Sharma\AppData\Local\Temp\pip-build-env-9zb8oms5\overlay’ --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple – setuptools ‘wheel>0.32.0,<0.33.0’ Cython ‘cymem>=2.0.2,<2.1.0’ ‘preshed>=2.0.1,<2.1.0’ ‘murmurhash>=0.28.0,<1.1.0’ ‘thinc>=7.0.8,<7.1.0’ cwd: None Complete output (135 lines): Collecting setuptools Using cached https://files.pythonhosted.org/packages/15/0e/255e3d57965f318973e417d5b7034223f1223de500d91b945ddfaef42a37/setuptools-53.0.0-py3-none-any.whl Collecting wheel<0.33.0,>0.32.0 Using cached https://files.pythonhosted.org/packages/ff/47/1dfa4795e24fd6f93d5d58602dd716c3f101cfd5a77cd9acbe519b44a0a9/wheel-0.32.3-py2.py3-none-any.whl Collecting Cython Using cached https://files.pythonhosted.org/packages/17/60/d7c00073e239e9650e38a17f03beca3480b538bd7a6921d7042cfb6bda43/Cython-0.29.21-cp38-cp38-win32.whl Collecting cymem<2.1.0,>=2.0.2 Using cached https://files.pythonhosted.org/packages/3e/fb/5899a59ee8d0f02202c1f02fe47671e0c93d1812b1deb2491505718473da/cymem-2.0.5.tar.gz Installing build dependencies: started Installing build dependencies: finished with status ‘done’ Getting requirements to build wheel: started Getting requirements to build wheel: finished with status ‘done’ Installing backend dependencies: started Installing backend dependencies: finished with status ‘done’ Preparing wheel metadata: started Preparing wheel metadata: finished with status ‘done’ Collecting preshed<2.1.0,>=2.0.1 Using cached https://files.pythonhosted.org/packages/0b/14/c9aa735cb9c131545fc9e23031baccb87041ac9215b3d75f99e3cf18f6a3/preshed-2.0.1.tar.gz Collecting murmurhash<1.1.0,>=0.28.0 Using cached https://files.pythonhosted.org/packages/0c/f3/0b5e06ddea555caeba56fd71f007c84b4e5b9fc3155b228ba2014e81f2ce/murmurhash-1.0.5.tar.gz Installing build dependencies: started Installing build dependencies: finished with status ‘done’ Getting requirements to build wheel: started Getting requirements to build wheel: finished with status ‘done’ Installing backend dependencies: started Installing backend dependencies: finished with status ‘done’ Preparing wheel metadata: started Preparing wheel metadata: finished with status ‘done’ Collecting thinc<7.1.0,>=7.0.8 Using cached https://files.pythonhosted.org/packages/92/39/ea2a3d5b87fd52fc865fd1ceb7b91dca1f85e227d53e7a086d260f6bcb93/thinc-7.0.8.tar.gz ERROR: Command errored out with exit status 1: command: ‘c:\users\aditya sharma\appdata\local\programs\python\python38-32\python.exe’ -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’“‘C:\Users\Aditya Sharma\AppData\Local\Temp\pip-install-ia5gmh3p\thinc\setup.py’”’“‘; file=’”‘“‘C:\Users\Aditya Sharma\AppData\Local\Temp\pip-install-ia5gmh3p\thinc\setup.py’”’“';f=getattr(tokenize, '”‘“‘open’”’“‘, open)(file);code=f.read().replace(’”‘"’\r\n’“'”‘, ‘"’"’\n’“'”‘);f.close();exec(compile(code, file, ‘"’“‘exec’”’"‘))’ egg_info --egg-base pip-egg-info cwd: C:\Users\Aditya Sharma\AppData\Local\Temp\pip-install-ia5gmh3p\thinc
Complete output (97 lines): Processing numpy/random_bounded_integers.pxd.in Processing numpy/random\bit_generator.pyx Traceback (most recent call last): File “C:\Users\ADITYA~1\AppData\Local\Temp\easy_install-qr26y_k0\numpy-1.20.1\tools\cythonize.py”, line 59, in process_pyx from Cython.Compiler.Version import version as cython_version ModuleNotFoundError: No module named ‘Cython’
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. WARNING: You are using pip version 19.2.3, however version 21.0.1 is available. You should consider upgrading via the ‘python -m pip install --upgrade pip’ command.
ERROR: Command errored out with exit status 1: ‘c:\users\aditya sharma\appdata\local\programs\python\python38-32\python.exe’ ‘c:\users\aditya sharma\appdata\local\programs\python\python38-32\lib\site-packages\pip’ install --ignore-installed --no-user --prefix ‘C:\Users\Aditya Sharma\AppData\Local\Temp\pip-build-env-9zb8oms5\overlay’ --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple – setuptools ‘wheel>0.32.0,<0.33.0’ Cython ‘cymem>=2.0.2,<2.1.0’ ‘preshed>=2.0.1,<2.1.0’ ‘murmurhash>=0.28.0,<1.1.0’ ‘thinc>=7.0.8,<7.1.0’ Check the logs for full command output.`