Howdy, Stranger!

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

Supported by

Pygame update

Hi,

I just wanted to ask whether the latest version of OpenSesame comes with pygame2.0. I tried to upgrade pygame in an older OpenSesame version and I was not able to do so. Is it even possible?

I am asking since the new pygame has quite cool functionalities for multi-touch responses and I would like to be able to use them within OpenSesame.

Many thanks!

Comments

  • Hi @SINE ,


    I'm tagging @sebastiaan to ask whether he could help out here.


    Cheers,


    Lotje

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • edited March 3

    Hi @SINE ,

    It depends on how you installed OpenSesame, but in most cases OpenSesame will use PyGame 1.9. You can see that when you start an experiment, because PyGame will print out its version to the console.

    My own test environment actually uses PyGame 2.0.1, and I haven't experienced any issues with that. (I wasn't even aware of it, to be honest.) So you can try upgrading by executing the following command in the console (if this doesn't work, see this page):

    !pip install pygame --upgrade
    

    — Sebastiaan

    Buy Me A Coffee

  • Hi Sebastiaan,

    many thanks for your reply. Strangely enough, I see that my pygame version is 1.9.6 and that for some reason it recognizes inputs such as pygame.FINGERDOWN, and pygame.FINGERMOTION, which I thought should be available only from pygame 2.0.1 onwards.

    I tried to upgrade pygame, but I get the message "Permission denied". I was wondering whether this may due to the fact that I am using OpenSesame with Python 2.7 and not 3.7.

    Thanks a lot!

  • Hi Sine,

    The permission issue should be unrelated to the version of Python you use. It suggests that you don't have the permissions to write to directories on your system that Opensesame is trying to access during upgrading.

    Perhaps it helps if you add the --user flag? This should install the package somewhere you have access to:

    !pip install pygame --upgrade --user
    

    (Maybe you have to remove the --upgrade part)

    !pip install pygame --user
    


    Buy Me A Coffee

  • Many thanks Eduard,

    it works now! 🤗

    I take this occasion also to ask you a doubt that came to me about drawing stimuli using the pygame/legacy back-end. From what I could understand, in Pygame you do not clear the canvas, but, everytime that you have to draw a new stimulus, you re-fill the display with the background colour and re-write onto it the new stimulus. I am coding an experiment with many trials (about 700). How does this work in terms of the timing of the experiment? Would the display keep in memory all the stimuli that are drawn onto it and therefore I may risk having an experiment that crashes? Unfortunately, I need Pygame to work with the touch responses, so I do not think that I have many alternatives (ps note that I have coded the experiment and I am using the inline scripts bits, so I am not relying on the sketchpads).

    Apologies for the naive question, but I could not find information about this in the web.

    Thanks!

  • Also, do you believe that it is actually possible to register touch responses in opensesame by using pygame._sdl2 or is there any constraint that I would not be able to get around?

    Thanks again for your precious help!

  • Dear @eduard ,

    going back to my original question about installing the last version of pygame, that works successfully:

    pygame 2.0.1 (SDL 2.0.14, Python 3.7.6)
    Hello from the pygame community. https://www.pygame.org/contribute.html
    

    However, once I click run the experiment, not matter what I do (whether I restart or not), the experiment is by default run with pygame 1.9.6:

    Starting experiment as ExperimentProcess-3
    pygame 1.9.6
    Hello from the pygame community. https://www.pygame.org/contribute.html
    [2021-03-15 15:07:06,302:psycho:146:INFO] waitblanking = True
    [2021-03-15 15:07:06,302:psycho:147:INFO] monitor = testMonitor
    [2021-03-15 15:07:06,302:psycho:148:INFO] screen = 0
    [2021-03-15 15:07:07,733:experiment:464:INFO] experiment started
    [2021-03-15 15:07:07,733:experiment:468:INFO] disabling garbage collection
    [2021-03-15 15:07:08,063:experiment:552:INFO] enabling garbage collection
    
    Error while executing inline script
    
    item: new_inline_script
    phase: prepare
    item-stack: experiment[prepare].new_inline_script[prepare]
    time: Mon Mar 15 15:07:07 2021
    exception type: ModuleNotFoundError
    exception message: No module named 'pygame._sdl2'
    

    This is strange, because if I type "import pygame" in the debug window, the version of pygame results to be 2.0.1. However, when I run the experiment with the green arrow pygame 1.9.6 "kicks in" and I cannot use the module pygame._sdl2, which is available just for pygame 2.0.1.

    Do you know how I could solve this problem?

    Many thanks!

  • Hi Sine,

    From what I could understand, in Pygame you do not clear the canvas, but, everytime that you have to draw a new stimulus, you re-fill the display with the background colour and re-write onto it the new stimulus

    I am not entirely sure, but the way I read it is that filling the display is just another way of clearing it. In this sense, you could see clearing a window as similar to filling it with black, so that pygame just makes it explicit and, additionally, allows users to specify which color to use for filling, that is clearing the screen.

    So, you should not experience increasing lags with increasing trial number (if this happened, that would be quite inacceptable behavior of pygame!)

    Also, do you believe that it is actually possible to register touch responses in opensesame by using pygame._sdl2 or is there any constraint that I would not be able to get around?

    I don't know this package, but if it is a Python package it most likely will work with Opensesame. You just need to install and import it. I suppose there are examples of how to interact with it? Then you could try to follow it and see how far you got.

    However, once I click run the experiment, not matter what I do (whether I restart or not), the experiment is by default run with pygame 1.9.6:

    That is a bit weird. The only reason I can see for that behaviour is that Opensesame ignores your local installation of Pygame. Why this would happen, I don't know. @sebastiaan do you have an idea?

    As a dirty fix for now, you can try to reload your version of pygame once the experiment has started:

    from importlib import reload  
    reload(pygame)
    

    That might work. No clue whether it will cause weird behaviour with the rest of Opensesame.

    Let us know whether it works.

    Eduard

    Buy Me A Coffee

  • edited March 16

    Hi @SINE and @eduard ,

    This is strange, because if I type "import pygame" in the debug window, the version of pygame results to be 2.0.1. However, when I run the experiment with the green arrow pygame 1.9.6 "kicks in" and I cannot use the module pygame._sdl2, which is available just for pygame 2.0.1.

    This means that you have two versions of PyGame installed, and for some reason (possibly related to paths) it picks up a different version depending on the situation. As a first step, it would be useful to see where the packages are actually located. You can do that by running the following code in the console:

    import pygame
    print('PyGame {} is installed in {}'.format(pygame.__version__, pygame.__file__))
    

    Which for me gives:

    And then including the same code in an inline_script and running the experiment. That should tell you where the different versions of PyGame are located, and then you can probably remove them.

    — Sebastiaan

    Buy Me A Coffee

  • Dear @sebastiaan and @eduard,

    many thanks for your answers. I have done as suggested, but for some reason pygame 2.0.1 does not seem to work on the computer with OpenSesame. The error that I keep getting is:

    Traceback:
      File "C:\Program Files (x86)\OpenSesame\Lib\site-packages\libqtopensesame\misc\process.py", line 158, in run
        exp.run()
      File "C:\Program Files (x86)\OpenSesame\Lib\site-packages\libopensesame\experiment.py", line 451, in run
        self.init_display()
      File "C:\Program Files (x86)\OpenSesame\Lib\site-packages\libopensesame\experiment.py", line 731, in init_display
        canvas.init_display(self)
      File "C:\Program Files (x86)\OpenSesame\Lib\site-packages\openexp\canvas.py", line 64, in init_display
        cls.init_display(experiment)
      File "C:\Program Files (x86)\OpenSesame\Lib\site-packages\openexp\_canvas\legacy.py", line 178, in init_display
        pygame.display.set_icon(surf)
    error: directx not available
    

    I checked online and there does not seem to be much about this problem. The weird thing is that I have a laptop with same drivers and same windows (10) as the computer in the lab and for the laptop everything works fine.

    I have tried every possible attempt and asked help to the IT team here, but the problem persists. Would you have an intuition about what this problem may be about?

    In any case, thanks for the help given so far, it has been very precious.

    Best

  • Hi @SINE ,

    I don't know where this error comes from. For me, on a Windows 10 machine, updating PyGame to 2.0.1 seems to work flawlessly. If I'd have to guess, I'd say that either the version of DirectX that is installed on your system is incompatible with PyGame, or that Python cannot find the necessary dll because of path issues. But those are just guesses!

    -- Sebastiaan

    Buy Me A Coffee

  • Many thanks @sebastiaan !

    Just to let you know what the problem was (if someone encounters it in the future), there were two reasons why I was getting that error:

    1) one of the graphic drivers of the computer was incompatible with pygame

    2) one of the Eyelink files on the computer interfered with pygame. We have not understood yet specifically what file was causing this, but that seemed to be the problem.

    The experiment is now running smoothly. Thanks for your support!

    Best,

    Caterina

  • Hi @SINE ,

    Good to hear that you figured this out, and thanks for sharing!

    — Sebastiaan

    Buy Me A Coffee

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