Tag Archives: AttributeError: module ‘time‘ has no attribute ‘clock‘

AttributeError: module ‘time‘ has no attribute ‘clock‘ [How to Solve]

AttributeError: module ‘time’ has no attribute ‘clock’
Error Messages:

# `flask_sqlalchemy` Error:
File "D:\python38-flasky\lib\site-packages\sqlalchemy\util\compat.py", line 172, in <module>
    time_func = time.clock
AttributeError: module 'time' has no attribute 'clock'

reason:

Python 3.8 no longer supports time.clock, but it still contains this method when calling. There is a version problem.

Solution:

Use the replacement method: time.perf_Counter(), such as:

import time
if win32 or jython:
    # time_func = time.clock
    time_finc = time.perf_counter()
else:
    time_func = time.time