psychopy.org | Reference | Downloads | Github

Locale error when launching Coder

Since ver. 2020, there’ve been problems in launching PsychoPy Coder.
My environment is as follows:

OS: Windows 10 Pro 64 bit Japanese (maybe the language is critical)
Python: Minconda 3.7.7 (updated to the latest)
PsychoPy: 2020.1.3

Right after the install, PsychoPy fails to start. From Anaconda Prompt, ‘psychopy’ command seems start the app and the logo window comes up, but not the main window.

Then I found ‘psychopy -b’ can start Builder and Runner. From successfully opened Builder, launching Coder generates error messages in Runner’s stdout as follows:

Traceback (most recent call last):
File “c:\miniconda\lib\site-packages\psychopy\app_psychopyApp.py”, line 556, in showCoder
files=fileList, app=self)
File “c:\miniconda\lib\site-packages\psychopy\app\coder\coder.py”, line 1085, in init
self.fileBrowserWindow = FileBrowserPanel(self.sourceAsst, self)
File “c:\miniconda\lib\site-packages\psychopy\app\coder\fileBrowser.py”, line 228, in init
self.gotoDir(os.getcwd())
File “c:\miniconda\lib\site-packages\psychopy\app\coder\fileBrowser.py”, line 610, in gotoDir
if not self.scanDir(path): # if failed, return the current directory
File “c:\miniconda\lib\site-packages\psychopy\app\coder\fileBrowser.py”, line 548, in scanDir
time.strptime(modTime, “%a %b %d %H:%M:%S %Y”))
File “c:\miniconda\lib_strptime.py”, line 571, in _strptime_time
tt = _strptime(data_string, format)[0]
File “c:\miniconda\lib_strptime.py”, line 359, in _strptime
(data_string, format))
ValueError: time data ‘Sun Mar 29 18:46:41 2020’ does not match format ‘%a %b %d %H:%M:%S %Y’

It seems that dealing locale in fileBrowser.py does something wrong.

Adding ‘import locale’ to the file’s top and ‘locale.setlocale(locale.LC_TIME, ‘en_us.UTF-8’)’ into the ‘FileBrowserPanel’ class fixed the error.

class FileBrowserPanel(wx.Panel):
    """Panel for a file browser.
    """
    def __init__(self, parent, frame):
        locale.setlocale(locale.LC_TIME, 'en_us.UTF-8')
        wx.Panel.__init__(self, parent, -1)

Since I’m not a python expert, I’m not sure this is a good workaround.
Anyway, I want the next version will include a fix to this problem.