Howdy, Stranger!

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

Supported by

[solved] 'ascii' codec can't decode byte 0xc3 in position 27: ordinal not in range

edited June 2014 in OpenSesame

Even though I already found another entry on this problem, I think, I cannot solve it the same way in my case but putting a 'u in the logger :P

So what happened: the experiment runs fine on my laptop but not on the computers in the lab at university.
It crashes as soon as a loop containin an inline script to set the string according to the current value of a variable, a form which contains some text, a picture, some checkboxes, a button and another inline script which creates a new variable each cycle of the loop, so that I only need one logger-Item in the end and have my values in one line.

Here's the error message in the debugging window:

Unexpected error

line: 874
exception message: 
exception type: UnicodeDecodeError

Traceback:
  File "dist\libqtopensesame\misc\process.py", line 130, in run
  File "dist\libopensesame\experiment.py", line 291, in run
  File "dist\libopensesame\sequence.py", line 56, in run
  File "dist\libopensesame\loop.py", line 145, in run
  File "dist\libopensesame\sequence.py", line 56, in run
  File "C:\Program Files (x86)\OpenSesame\plugins\form_base\form_base.py", line 136, in run
  File "dist\libopensesame\widgets\form.py", line 112, in _exec
  File "dist\libopensesame\widgets\form.py", line 224, in render
  File "dist\libopensesame\widgets\image.py", line 73, in render
  File "dist\openexp\_canvas\legacy.py", line 874, in image
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 27: ordinal not in range(128)

OS on the lab computers, where it crashes, is Win 7 Enterprise 64bit
OS on my Laptop where it was created and runs propperly is Win 8.1 64bit

I'd be thankful for a solution. Meanwhile participants use my laptop.
Cheers!

Comments

  • edited 6:41PM

    Hi,

    The error message that you see results from a problem in parsing the actual error message. In other words, the actual error message is obscured by a bug in OpenSesame's exception handling system. To see what's going, you try the following code in an inline_script:

    import pygame
    pygame.image.load(exp.get_file(u'my_filename.png'))
    

    ... replace my_filename.png by the name of the problematic file in the file pool. This script should still crash, but hopefully provide a more informative error message.

    Cheers!
    Sebastiaan

  • edited 6:41PM

    Hi Sebastiaan,

    Had to change the inline script slightly to match my usage:

    import pygame
    path = "u'%s.png'" % (self.get('ID'))
    pygame.image.load(path)
    

    The Error code now produced by this new inline script is as following:

    Error while executing inline script
    
    phase: run
    item: inline_script
    line: 3
    exception message: Couldn't open u'52.png'
    exception type: error
    
    Traceback:
      File "dist\libopensesame\inline_script.py", line 154, in run
      Inline_script, line 3, in <module>
    error: Couldn't open u'52.png'
    

    An image 52.png exists in the same folder as the experiment. And adding all the pictures to the file pool did not help either.

  • edited June 2014

    The correct code would actually be:

    import pygame
    path = u'%s.png' % (self.get('ID'))
    pygame.image.load(path)
    

    The u should be before the quotation marks if you use it to denote a unicode string. Currently, your image name is defined as u'52.png' rather than 52.png

  • edited 6:41PM

    Thanks Edwin for the correction.
    And I just realized it's jpg not png, so I corrected the path accordingly. Could the jpg-format cause the problem?

    Now the error is:

    Error while executing inline script
    
    phase: run
    item: inline_script
    line: 3
    exception message: Couldn't open 52.jpg
    exception type: error
    
    Traceback:
      File "dist\libopensesame\inline_script.py", line 154, in run
      Inline_script, line 3, in <module>
    error: Couldn't open 52.jpg
    

    Still, all pictures are in the same folder as the experiment and all pictures were added to the file pool.

    But don't worry too much, it's not critical anymore. I got used to make my participants switch seats and use my laptop for this part.

  • edited June 2014

    Hi,

    It seems OpenSesame still can't find the file. One thing that comes to mind, is using the neat way of getting file paths, using the function that @sebastiaan had already mentioned:

    import pygame
    
    # get the file name, e.g. u'52.png'
    filename = u'%s.png' % (self.get('ID'))
    
    # get the full path to the file
    path = exp.get_file(filename)
    
    # load the image, using the full path
    pygame.image.load(path)
    

    This way is preferred, as some systems are not particularly fond of abbreviated paths (i.e.: not using the full path, but just the name of a file in the working directory).

    Good luck!

  • edited 6:41PM

    Even though the thread was meanwhile marked as solved, I must admit, I just didn't try it anymore on the lab's PCs and just used my laptop. Meanwhile I'm done with this study. So thank you for all the support, Edwin and Sebastiaan! =) (a short review concerning the mobile part will be given in the runtime environment threat)

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