psychopy.org | Reference | Downloads | Github

Error with getAbsTime

Hi all.

I would like to include the absolute timing of some components of my experiment in the data print out. I’m attempting to use getAbsTime, but am getting the following error when using the function in psychopy:

“AttributeError: ‘Clock’ object has no attribute ‘getAbsTime’”

It appears that psychopy isn’t recognizing getAbsTime as a defined function. See details on another post I recently made. I printed out the functions defined in core, in which getAbsTime appears to be present.

from psychopy import core
print core
<module 'psychopy.core' from 'C:\\Program Files\\PsychoPy3\\lib\\site-packages\\psychopy\\core.py'>
print dir(core)
['Clock', 'CountdownTimer', 'FINISHED', 'MonotonicClock', 'NOT_STARTED', 'PY3', 'STARTED', 'StaticPeriod', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'absolute_import', 'checkPygletDuringWait', 'division', 'getAbsTime', 'getTime', 'haveGLFW', 'havePyglet', 'locale', 'logging', 'monotonicClock', 'object', 'openWindows', 'print_function', 'pyglet', 'quit', 'runningThreads', 'rush', 'shellCall', 'shlex', 'subprocess', 'sys', 'threading', 'wait']

Any ideas why I’m getting this error? Thanks for your help!

Hi @novasdid, you get the error because getAbsTime is imported but not defined in the core module. If you want to use getAbsTime, then try the following

from psychopy import core
print(core.getAbsTime())