7

I am running into an issue where plyplus is erroring out with:

  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() + ']' to my settings.py and run the Django server from PyCharm (2016.3.1) I see LOCALE: [] this when I start my server.

If I run the server from the command line, I see LOCALE: [UTF-8] and the plyplus issue goes away.

Can anyone tell me what I need to do in PyCharm to get the proper encoding set in my Django server?

Krystian Cybulski
  • 10,789
  • 12
  • 67
  • 98

2 Answers2

11

PyCharm passes a blank value for the LC_CTYPE environment variable.

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

My shell has this environment variable set. It's strange that PyCharm sets it to a blank value.

Krystian Cybulski
  • 10,789
  • 12
  • 67
  • 98
0

Coming from OSX 10.14.2, I fixed it by changing my primary language to English (US) instead of English.

This is also discussed here: https://stackoverflow.com/a/38557558/4960855

EliadL
  • 6,230
  • 2
  • 26
  • 43