PyCharm changes the default encoding in my Django application

I have a problem with plyplus error:

  File "/Users/FOO/.virtualenvs/ff/lib/python2.7/site-packages/plyplus/grammars/__init__.py", line 6, in open return _open( os.path.join(os.path.dirname(__file__), grammar_name) ) LookupError: unknown encoding: [06/Jan/2017 22:27:45] "GET / HTTP/1.0" 500 200257 

If I add import locale; print 'LOCALE: [' + locale.getpreferredencoding() + ']' import locale; print 'LOCALE: [' + locale.getpreferredencoding() + ']' into my settings.py and launched the Django server from PyCharm (2016.3.1), I see LOCALE: [] this is when my server starts.

If I start the server from the command line, I see LOCALE: [UTF-8] and the plyplus problem disappears.

Can someone tell me what I need to do in PyCharm in order to get the correct encoding on my Django server?

+7
source share
2 answers

PyCharm passes an empty value for the LC_CTYPE environment variable.

I need to explicitly add an environment variable to my startup configuration: LC_CTYPE=en_US.UTF-8

This set of environment variables is installed in my shell. It is strange that PyCharm sets it to an empty value.

+9
source

Based on OSX 10.14.2, I fixed this by changing my primary language to English (US) instead of English .

This is also discussed here: fooobar.com/questions/2102244 / ...

0
source

Source: https://habr.com/ru/post/1262448/


All Articles