| Reference | Downloads | Github

# -*- coding: utf-8 -*- ruins my code


I’ve started programming my experiment without these two lines at the beginning of the code.

#!/usr/bin/env python2
# -*- coding: utf-8 -*-

After I realized that my instruction text (text=u’Drücke irgendeine Taste’) includes german “Umlaute” (like ä, ö, ü) I added those two lines to avoid this error:

Non-ASCII character '\xc3' in file, but no encoding declared

Since I added those two lines, following error occurs:

Exception UnicodeDecodeError: UnicodeDecodeError('utf8', MY WHOLE CODE)

The experiment runs without a problem but when it’s finished, this error is shown and also no .csv data file is saved. When I run a simple experiment created with the builder and then translated into code (which also has the two lines of code from above) no such error occurs.

Has anyone a solution for this error?

I’m using psychopy v1.82.01 and tested the code on windows 10 as well as OS X 10.14.6. (No difference)