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 8:34PM


    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'

  • It's simply because there is no attribute with the name you called, for that Object. This means that you got the error when the "module" does not contain the method you are calling. But it is evident that the method is there, which leads to believe that may be the method was added by you in the python source code after you had already imported the file (module). Or, some times packages get deprecated and they rename some functions. If that is true, then you may want to exit and reimport the module once again to be able to access the new method.

    You can do it in another way to reimport the module with changes without having to exit the interpreter is to do the following:

    import importlib


Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games