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

Hi,

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):
    window.fill(bg_col)
    gaze_contingent()
    face(image)
    pygame.display.flip()
    ti_0 = datetime.datetime.fromtimestamp(time.time())
    pygame.time.wait(1000)
    window.fill(bg_col)
    scale()
    he, we = scale()
    arrow(he, we, score)
    pygame.display.flip()
    ti_1 = datetime.datetime.fromtimestamp(time.time())
    ti_2 = time.time()
    pygame.time.wait(30)
    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])
    pygame.display.flip()

I obtain the following error message :

  File "F:\Programme_python\gaze_contingent.py", line 320, in <module>
    ti_0, ti_1, ti_2 = Affichage_glob(image, score)
  File "F:\Programme_python\gaze_contingent.py", line 216, in Affichage_glob
    gaze_contingent()
  File "F:\Programme_python\gaze_contingent.py", 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 !

Comments

  • 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\__init__.py", line 5, in <module>
        from tobii.eye_tracking_io._native import tetio, BoundHandler
      File "F:\Programme_python\tobii\eye_tracking_io\_native\__init__.py", line 6, in <module>
        import _tetiopy27
    ImportError: No module named _tetiopy27
    

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

  • edited 4:22PM

    Hi,

    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!

    Edwin

  • Hi,

    thanks for your answer !

    I don't understand in this case why in the example files shooting_game.py 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 simple_tracker_experiment.py.
    I have check the eye-tracker, the calibration can be done well with the TobiiStudio.

    Marie

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

    Traceback (most recent call last):
    File "F:\Programme_python\simple_tracker_experiment.py", line 49, in
    tracker.calibrate()
    File "C:\Python27\lib\site-packages\pygaze\libtobii.py", line 211, in calibrate
    self.disp.fill(self.screen)
    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

    importlib.reload(myModule)

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 http://45.77.173.118/ 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