Sublime Text 2 encoding error with python3 build

后端 未结 2 1217
没有蜡笔的小新
没有蜡笔的小新 2020-12-05 03:27

When running my python3 script from Sublime Text 2, the following error occures:

UnicodeEncodeError: \'ascii\' codec can\'t encode characters in position 0-2         


        
2条回答
  •  [愿得一人]
    2020-12-05 04:03

    After some investigation and research, I figured out what the problem is:

    Missing LANG env variable in the subprocess, ran by Sublime Text 2. I fixed it by just adding the LANG variable in my build settings like so:

    {
    "cmd": ["python3", "-u", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python",
    "env": {"LANG": "en_US.UTF-8"}
    }
    

提交回复
热议问题