| Reference | Downloads | Github

UnicodeEncodeError appearing randomly

OS (e.g. Win10): Mac OS 10.12.5
PsychoPy version (e.g. 1.84.x): 1.85.2
Standard Standalone? (y/n) If not then what?: Yes
What are you trying to achieve?: Experiment with images in .xlsx file was working fine for a day before UnicodeEncodeError in sound file began popping up (not sure starting from when; didn’t change anything; ran the experiment numerous times in the same day and the first few times worked fine)

What did you try to make it work?: Looked through almost all related questions, but not sure what is meant by the “print” line in some of the answers. Where is the print line? In which file?

What specifically went wrong when you tried that?: My error message:

Running: /Users/Home/Desktop/TEST - Group 1/GROUP 1 - chinese character
pyo version 0.8.6 (uses single precision)
Traceback (most recent call last):
File “/Users/Home/Desktop/TEST - Group 1/GROUP 1 - chinese character”, line 18, in
from psychopy import locale_setup, sound, gui, visual, core, data, event, logging
File “/Applications/”, line 143, in
elif dev not in backend.getDevices(kind=‘output’):
File “/Applications/”, line 68, in getDevices
devName = dev[‘name’].decode(osEncoding) # convert to unicode
File “encodings/utf_8.pyc”, line 16, in decode
UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position 0-1: ordinal not in range(128)

Could you check again that you’re running 1.85.2 (do you have multiple versions installed maybe?)
This was a bug in 1.85.1 when your sound card had unicode characters in its name, but I believe we fixed it in 1.85.2

Hi Jon,

Thanks for your reply. Yes, I’m running 1.85.2, and I also made sure to check it in the experimental settings. Yesterday, it was working fine but then this morning, the same error message started popping up again. I’ve uninstalled and reinstalled the app a bunch of times now.

Because of this line: osEncoding = sys.getfilesystemencoding() in the file, I thought it might be related to the languages I have set in the system preferences on my laptop, namely that there seemed to be a problem with PyschoPy when I added Chinese. But this is totally my own uneducated guess…