question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AttributeError: module 'time' has no attribute 'clock'

See original GitHub issue

When 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:closed
  • Created 3 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
Azeemaj101commented, Mar 22, 2022

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

2reactions
adityasharmaayyagaricommented, Feb 17, 2021

Alright sorry for the late response, that worked fine, for some reason pip didn’t install the latest version by default, not sure why… i had to manually do pip install chatterbot==1.0.7

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’

  During handling of the above exception, another exception occurred:

  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 235, in <module>
      main()
    File "C:\Users\ADITYA~1\AppData\Local\Temp\easy_install-qr26y_k0\numpy-1.20.1\tools\cythonize.py", line 231, in main
      find_process_files(root_dir)
    File "C:\Users\ADITYA~1\AppData\Local\Temp\easy_install-qr26y_k0\numpy-1.20.1\tools\cythonize.py", line 222, in find_process_files
      process(root_dir, fromfile, tofile, function, hash_db)
    File "C:\Users\ADITYA~1\AppData\Local\Temp\easy_install-qr26y_k0\numpy-1.20.1\tools\cythonize.py", line 188, in process
      processor_function(fromfile, tofile)
    File "C:\Users\ADITYA~1\AppData\Local\Temp\easy_install-qr26y_k0\numpy-1.20.1\tools\cythonize.py", line 64, in process_pyx
      raise OSError('Cython needs to be installed in Python as a module')
  OSError: Cython needs to be installed in Python as a module
  Running from numpy source directory.
  C:\Users\ADITYA~1\AppData\Local\Temp\easy_install-qr26y_k0\numpy-1.20.1\setup.py:485: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates
    run_build = parse_setuppy_commands()
  Traceback (most recent call last):
    File "c:\users\aditya sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\sandbox.py", line 154, in save_modules
      yield saved
    File "c:\users\aditya sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\sandbox.py", line 195, in setup_context
      yield
    File "c:\users\aditya sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\sandbox.py", line 250, in run_setup
      _execfile(setup_script, ns)
    File "c:\users\aditya sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\sandbox.py", line 45, in _execfile
      exec(code, globals, locals)
    File "C:\Users\ADITYA~1\AppData\Local\Temp\easy_install-qr26y_k0\numpy-1.20.1\setup.py", line 513, in <module>
    File "C:\Users\ADITYA~1\AppData\Local\Temp\easy_install-qr26y_k0\numpy-1.20.1\setup.py", line 493, in setup_package
    File "C:\Users\ADITYA~1\AppData\Local\Temp\easy_install-qr26y_k0\numpy-1.20.1\setup.py", line 290, in generate_cython
  RuntimeError: Running cythonize failed!

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Users\Aditya Sharma\AppData\Local\Temp\pip-install-ia5gmh3p\thinc\setup.py", line 261, in <module>
      setup_package()
    File "C:\Users\Aditya Sharma\AppData\Local\Temp\pip-install-ia5gmh3p\thinc\setup.py", line 201, in setup_package
      setup(
    File "c:\users\aditya sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\__init__.py", line 144, in setup
      _install_setup_requires(attrs)
    File "c:\users\aditya sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\__init__.py", line 139, in _install_setup_requires
      dist.fetch_build_eggs(dist.setup_requires)
    File "c:\users\aditya sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\dist.py", line 716, in fetch_build_eggs
      resolved_dists = pkg_resources.working_set.resolve(
    File "c:\users\aditya sharma\appdata\local\programs\python\python38-32\lib\site-packages\pkg_resources\__init__.py", line 780, in resolve
      dist = best[req.key] = env.best_match(
    File "c:\users\aditya sharma\appdata\local\programs\python\python38-32\lib\site-packages\pkg_resources\__init__.py", line 1065, in best_match
      return self.obtain(req, installer)
    File "c:\users\aditya sharma\appdata\local\programs\python\python38-32\lib\site-packages\pkg_resources\__init__.py", line 1077, in obtain
      return installer(requirement)
    File "c:\users\aditya sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\dist.py", line 786, in fetch_build_egg
      return cmd.easy_install(req)
    File "c:\users\aditya sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\command\easy_install.py", line 679, in easy_install
      return self.install_item(spec, dist.location, tmpdir, deps)
    File "c:\users\aditya sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\command\easy_install.py", line 705, in install_item
      dists = self.install_eggs(spec, download, tmpdir)
    File "c:\users\aditya sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\command\easy_install.py", line 890, in install_eggs
      return self.build_and_install(setup_script, setup_base)
    File "c:\users\aditya sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\command\easy_install.py", line 1158, in build_and_install
      self.run_setup(setup_script, setup_base, args)
    File "c:\users\aditya sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\command\easy_install.py", line 1144, in run_setup
      run_setup(setup_script, args)
    File "c:\users\aditya sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\sandbox.py", line 253, in run_setup
      raise
    File "c:\users\aditya sharma\appdata\local\programs\python\python38-32\lib\contextlib.py", line 131, in __exit__
      self.gen.throw(type, value, traceback)
    File "c:\users\aditya sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\sandbox.py", line 195, in setup_context
      yield
    File "c:\users\aditya sharma\appdata\local\programs\python\python38-32\lib\contextlib.py", line 131, in __exit__
      self.gen.throw(type, value, traceback)
    File "c:\users\aditya sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\sandbox.py", line 166, in save_modules
      saved_exc.resume()
    File "c:\users\aditya sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\sandbox.py", line 141, in resume
      six.reraise(type, exc, self._tb)
    File "c:\users\aditya sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\_vendor\six.py", line 685, in reraise
      raise value.with_traceback(tb)
    File "c:\users\aditya sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\sandbox.py", line 154, in save_modules
      yield saved
    File "c:\users\aditya sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\sandbox.py", line 195, in setup_context
      yield
    File "c:\users\aditya sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\sandbox.py", line 250, in run_setup
      _execfile(setup_script, ns)
    File "c:\users\aditya sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\sandbox.py", line 45, in _execfile
      exec(code, globals, locals)
    File "C:\Users\ADITYA~1\AppData\Local\Temp\easy_install-qr26y_k0\numpy-1.20.1\setup.py", line 513, in <module>
    File "C:\Users\ADITYA~1\AppData\Local\Temp\easy_install-qr26y_k0\numpy-1.20.1\setup.py", line 493, in setup_package
    File "C:\Users\ADITYA~1\AppData\Local\Temp\easy_install-qr26y_k0\numpy-1.20.1\setup.py", line 290, in generate_cython
  RuntimeError: Running cythonize failed!
  Cythonizing sources
  ----------------------------------------

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.`

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found