[Solved] AttributeError: module ‘time’ has no attribute ‘clock’ In SQLAlchemy python 3.8.2

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "", line 2, in <module>
    from flask_sqlalchemy import SQLAlchemy
  File "", line 18, in <module>
    import sqlalchemy
  File "", line 9, in <module>
    from .sql import (
  File "", line 8, in <module>
    from .expression import (
  File "", line 34, in <module>
    from .visitors import Visitable
  File "", line 28, in <module>
    from .. import util
  File "", line 8, in <module>
    from .compat import callable, cmp, reduce,  
  File "", line 234, in <module>
    time_func = time.clock
AttributeError: module 'time' has no attribute 'clock'

Solution #1:

The error occurs because in python 2, there is time.clock(), but in python 3, it has been replaced with time.perf_counter().

Just replace all the time.clock to time.perf_counter, and it should be fine. For more info:

Respondent: Ann Zen

Solution #2:

I had this issue with SQLAlchemy 1.2.10. Upgrading to the current version (1.3.18 as of now) fixed the problem

pip install sqlalchemy --upgrade
Respondent: EffinAndJeffin

Solution #3:

I found a solution that worked for me
I have a virtual environment carpet named env in which I installed sqlalchemy
Inside that there is this code:

   if sys.platform == 'win32':
        _timer = time.clock
        _timer = time.time

And I changed clock to perf_counter()
_timer = time.perf_counter()

Respondent: Mshel Alvarez

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Most Popular

To Top
India and Pakistan’s steroid-soaked rhetoric over Kashmir will come back to haunt them both clenbuterol australia bossier man pleads guilty for leadership role in anabolic steriod distribution conspiracy