8

I get the following error when I send form data to my Flask app. It says it will use the UTF-8 encoding, but the locale is already UTF-8. What does this error mean?

/home/.virtualenvs/project/local/lib/python2.7/site-packages/werkzeug/filesystem.py:63:
BrokenFilesystemWarning: Detected a misconfigured UNIX filesystem:
Will use UTF-8 as filesystem encoding instead of 'ANSI_X3.4-1968'
$ locale
LANG=en_US.utf8
LANGUAGE=en_US.utf8
LC_CTYPE="en_US.utf8"
LC_NUMERIC="en_US.utf8"
LC_TIME="en_US.utf8"
LC_COLLATE="en_US.utf8"
LC_MONETARY="en_US.utf8"
LC_MESSAGES="en_US.utf8"
LC_PAPER="en_US.utf8"
LC_NAME="en_US.utf8"
LC_ADDRESS="en_US.utf8"
LC_TELEPHONE="en_US.utf8"
LC_MEASUREMENT="en_US.utf8"
LC_IDENTIFICATION="en_US.utf8"
LC_ALL=en_US.utf8
davidism
  • 121,510
  • 29
  • 395
  • 339
Arti
  • 7,356
  • 12
  • 57
  • 122

2 Answers2

13

This is not a critical error, just a warning that Werkzeug couldn't detect a good locale and so is using UTF-8 instead. This guess is probably correct.

See this Arch Linux wiki article for how to set up the locale correctly. It mentions that Python may see the ANSI_X3.4-1968 encoding even if the locale is properly configured, if you are running from certain environments such as Vim.

When executing :!python -c "import sys; print(sys.stdout.encoding)" in ViM, the output may be ANSI_X3.4-1968, even if the locale is set correctly everyhere. Set the PYTHONIOENCODING environment variable to utf-8 to remedy the situation.

davidism
  • 121,510
  • 29
  • 395
  • 339
0

I saw this error too. After digging the code, I saw that this error is harmless and just a warning in /usr/local/lib/python2.7/dist-packages/werkzeug/filesystem.py:

        warnings.warn(
            'Detected a misconfigured UNIX filesystem: Will use UTF-8 as '
            'filesystem encoding instead of {0!r}'.format(rv),
            BrokenFilesystemWarning)

So, I would not worry about this warning.

Vikram Hosakote
  • 3,528
  • 12
  • 23
  • 1
    I've solved it. In my case I was running my script in a Docker container with a different Python version (3.6.9) that I used to develop and test it (3.7.5). So, now I've installed the same version into the container and don't get this error anymore. I hope this would be useful for others. – Sebastian Diaz May 19 '20 at 14:25