getdefaultlocale returning None when running sync.db on Django project in PyCharm

后端 未结 2 365
心在旅途
心在旅途 2021-02-03 14:32

OSX 10.7.3, PyCharm version 2.5 build PY 117.200

I\'ll run through how I get the error:

  1. I start a new project
  2. Create a new VirtualEnv and select P
相关标签:
2条回答
  • 2021-02-03 15:12

    Go onto Terminal:

    $ nano .bash_profile
    

    add:

    export LC_ALL=en_GB.UTF-8
    export LANG=en_GB.UTF-8
    

    (or use the locale -a command to see which ones are available to you)

    save and try again.

    0 讨论(0)
  • 2021-02-03 15:28

    Basically the reason this occurs is that PyCharm doesn't, by default, have access to environmental variables.

    I've found 3 solutions to this problem:

    1. Set a global environmental variable, using the link CrazyCoder suggests in the comments to this question.

    2. Run PyCharm from a terminal window by changing to the PyCharm application directory and running ./pycharm (possibly create a symlink in your PATH to make this less inconvenient)

    3. Open PyCharm preferences, browse to Console > Django Console, type in your required environmental variables as you would in your bash profile e.g. LC_ALL=en_US.UTF-8

    I'd suggest the 3rd way as most elegant, although it's annoying that variables aren't loaded by default.

    0 讨论(0)
提交回复
热议问题