Opened 4 years ago

Last modified 3 years ago

#6961 closed defect

AlphaFold prediction: A UTF-8 locale is required. Got ANSI_X3.4-1968 — at Version 1

Reported by: Tom Goddard Owned by: Tom Goddard
Priority: moderate Milestone:
Component: Structure Prediction Version:
Keywords: Cc:
Blocked By: Blocking:
Notify when closed: Platform: all
Project: ChimeraX

Description (last modified by Tom Goddard)

Restarting an AlphaFold prediction after an OpenMM minimization failure with minimization turned off by pressing the play button after an error gives the following error. This example is from the standard AlphaFold Colab notebook. The ChimeraX Colab notebook has the same problem. The problem is

import locale
locale.getpreferredencoding()

returns "ANSI_X3.4-1968" instead of the expected "UTF-8". Before the error the same call gave "UTF-8". So it seems reporting the error traceback somehow changed the preferred encoding. I was not able to remedy the problem with calls to locale.setlocale(). I could not find any way to get the preferred encoding back to "UTF-8". No relevant environment variables were set. If I redefine locale.getpreferredencoding() to always return 'UTF-8' then AlphaFold complete successfully.

If encoding is not 'UTF-8' then Google Colab is not able to execute any shell commands in the notebook.

---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-6-e612fd4aa5be> in <module>()
    210 
    211 # --- Download the predictions ---
--> 212 get_ipython().system('zip -q -r {output_dir}.zip {output_dir}')
    213 files.download(f'{output_dir}.zip')

2 frames
/usr/local/lib/python3.7/dist-packages/google/colab/_shell.py in system(self, *args, **kwargs)
    100       kwargs.update({'also_return_output': True})
    101 
--> 102     output = _system_commands._system_compat(self, *args, **kwargs)  # pylint:disable=protected-access
    103 
    104     if pip_warn:

/usr/local/lib/python3.7/dist-packages/google/colab/_system_commands.py in _system_compat(shell, cmd, also_return_output)
    445   # stack.
    446   result = _run_command(
--> 447       shell.var_expand(cmd, depth=2), clear_streamed_output=False)
    448   shell.user_ns['_exit_code'] = result.returncode
    449   if -result.returncode in _INTERRUPTED_SIGNALS:

/usr/local/lib/python3.7/dist-packages/google/colab/_system_commands.py in _run_command(cmd, clear_streamed_output)
    166   if locale_encoding != _ENCODING:
    167     raise NotImplementedError(
--> 168         'A UTF-8 locale is required. Got {}'.format(locale_encoding))
    169 
    170   parent_pty, child_pty = pty.openpty()

NotImplementedError: A UTF-8 locale is required. Got ANSI_X3.4-1968

Change History (1)

comment:1 by Tom Goddard, 4 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.