User Tools

Site Tools


wiki:python_locale_problem

Python locale problem

If you get this error or smth similar: UnicodeEncodeError: 'ascii' codec can't encode character '\u010c' in position 61: ordinal not in range(128)

Make sure the server has the locale set up correctly, usually it is enough to uncomment (en_US.UTF-8 UTF-8 and/or hr_HR.UTF-8 UTF-8):

vi /etc/locale.gen

Then run

locale-gen
locale

To verify what python sees enter python3 prompt:

python3
import sys
print(sys.getfilesystemencoding())

Should print “utf-8” not “ascii”.

Tested on

  • Ubuntu 18.04

See also

References

wiki/python_locale_problem.txt · Last modified: 2021/05/19 14:14 by antisa

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki