I have a NGINX -> UWSGI -> Django(python) stack installed on an Ubuntu AMI on Amazon EC2. I've run into a problem when accessing a file with unicode characters in the name. The exact output from the Django App (Mezzanine) is
Access was attempted on a file that contains unicode characters in its path, but somehow the current locale does not support utf-8. You may need to set 'LC_ALL' to a correct value, eg: 'en_US.UTF-8'.
Now when I run the
locale command the output is:
LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8 LC_CTYPE="en_US.UTF-8" LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_PAPER="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8" LC_ALL=en_US.UTF-8
To me everything looks good there, so next I added some code to print out the locale settings in the section of code that generates the error.
The result of that is:
locale.getdefaultlocale() = (None, None) locale.getpreferredencoding() = 'ANSI_X3.4-1968' sys.getdefaultencoding() = 'ascii' sys.getfilesystemencoding() = 'ANSI_X3.4-1968'
So that looks wrong but I'm not sure how to fix it. When I run the same code in a python shell everything looks a lot better.
locale.getdefaultlocale() = ('en_US', 'UTF-8') locale.getpreferredencoding() = 'UTF-8' sys.getdefaultencoding() = 'ascii' sys.getfilesystemencoding() = 'UTF-8'
So my only thought is that somewhere in the nginx and uwsgi portion the locale is not being set properly. Is there anyway to force either of those to use a certain locale? Or could it be something with the user? It is a different user that's running nginx and uwsgi than what I was using to run those commands in the shell.