psychopy.org | Reference | Downloads | Github

Exporting to html - problem with encoding

I’ve found unexpected error while exporting procedure from PsychoPy v1.85.1 to html. It seems that there is a problem with encoding. However I don’t know how to deal with it.

Any ideas?

Welcome to PsychoPy2!
v1.85.1
Traceback (most recent call last):
File “/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/app/builder/builder.py”, line 1624, in fileExport
target=“PsychoJS”)
File “/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/app/builder/builder.py”, line 2141, in generateScript
target=target)
File “/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/app/builder/experiment.py”, line 231, in writeScript
entry.writeInitCodeJS(script)
File “/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/app/builder/experiment.py”, line 1933, in writeInitCodeJS
thisCompon.writeInitCodeJS(buff)
File “/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/app/builder/components/text/init.py”, line 130, in writeInitCodeJS
inits = getInitVals(self.params, ‘PsychoJS’)
File “/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/app/builder/components/init.py”, line 231, in getInitVals
valStr = str(inits[name].val).strip()
UnicodeEncodeError: ‘ascii’ codec can’t encode character u’\u0119’ in position 12: ordinal not in range(128)

We’ve managed to circumvent the problem by throwing out text content of TextStim objects (which contained non-ascii characters). Is this something that was solved recently (I have a vague recollection that it was mentioned on github some time ago)?

Ah, looks like there’s still a reference to str() that shouldn’t be there. Maciek, could you try editing the file
/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/app/builder/components/__init__.py and replacing all instances of:

str(

with

unicode(

Ok, I’ve found 2 instances of

str(

and replaced it with

unicode(

as you suggested. After that PsychoPy do not inform about any error during exporting to html and index.html file is being successfully been created. It seems that everything is just fine. Thank You!