Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[open] AttributeError: 'module' object has no attribute 'sample'

edited February 2015 in PyGaze


I'am working on a gaze-contingent project and was really happy to read that PyGaze can help me because I just begin to use Python. But I have troubles with the following code which I created to achieve my purpose :

# create display object
disp = libscreen.Display()

# create eyetracker object
tracker = eyetracker.EyeTracker(disp)

def Affichage_glob(image, score):
    ti_0 = datetime.datetime.fromtimestamp(time.time())
    he, we = scale()
    arrow(he, we, score)
    ti_1 = datetime.datetime.fromtimestamp(time.time())
    ti_2 = time.time()
    return ti_0, ti_1, ti_2

trou = pygame.image.load('trou.png')
wg, hg = trou.get_size()

def gaze_contingent():
    x, y = eyetracker.sample()
    window.blit(trou, [- wg/2+c_x, - hg/2+c_y])

I obtain the following error message :

  File "F:\Programme_python\", line 320, in <module>
    ti_0, ti_1, ti_2 = Affichage_glob(image, score)
  File "F:\Programme_python\", line 216, in Affichage_glob
  File "F:\Programme_python\", line 272, in gaze_contingent
    x, y = eyetracker.sample()
AttributeError: 'module' object has no attribute 'sample'

Can you explain to me why, and how to solve it ?

Many thanks for your help !


  • edited February 2015

    I am very sorry for my stupid question, I just forgot to switch the DUMMYMODE from False to True...
    But I have now a new error :

      File "F:\Programme_python\tobii\eye_tracking_io\", line 5, in <module>
        from tobii.eye_tracking_io._native import tetio, BoundHandler
      File "F:\Programme_python\tobii\eye_tracking_io\_native\", line 6, in <module>
        import _tetiopy27
    ImportError: No module named _tetiopy27

    I have looked for that module in internet but found nothing.

  • edited 5:12PM


    Actually, your first error did not arise from not using DUMMYMODE. In dummy mode, you should still be able to get samples (the mouse serves as a simulated eye tracker).

    What did cause the error, is that you use eyetracker.sample rather than tracker.sample. The former refers to the entire module eyetracker, whereas the latter refers to the instance tracker (which is the one you want to use to get samples).

    Additionally, you seem to be mixing PyGame with PyGaze functions, which is not necessarily wrong, but it kind of defeats the purpose of PyGaze providing you the same functionality without directly having to use PyGame (you can opt for a PsychoPy back-end as well).

    Finally, the import error suggests that you might not have installed the Tobii SDK properly. The weird path ("F:\Programme_python\tobii") seems to suggest the same thing. Usually, installed modules should go to the site-packages directory of your Python installation.

    Good luck!


  • Hi,

    thanks for your answer !

    I don't understand in this case why in the example files there is eyetracker.sample()... (line 60) what is the difference with what I am doing ?

    I have written all my code, in the perspective to take measures by the Eye-Tribe, when we realize that the Eye-Tribe was not the better device for our work and that adding a gaze-contingent function will be great... That's only at that time I discover Pygaze. It take me a very long time, I hope I wont have to rewrite everything.

    I have all uninstall and reinstall, that's ok now.

    But I have a new problem : my program start, I have a message "Start calibration" and a window with a light brown fond color and a green circle appear. Then, it freeze and nothing else append.
    I have the same problem when I try to run
    I have check the eye-tracker, the calibration can be done well with the TobiiStudio.


  • Sorry, I forgot to give you the error message about my last problem :

    Traceback (most recent call last):
    File "F:\Programme_python\", line 49, in
    File "C:\Python27\lib\site-packages\pygaze\", line 211, in calibrate
    AttributeError: 'str' object has no attribute 'fill'

Sign In or Register to comment.