Unicode Encode Error in Sublime Text 3 console

依然范特西╮ 提交于 2020-01-01 07:05:15

问题


I’m always getting a

'UnicodeEncodeError: 'ascii' codec can't encode character '\xf6' in position 0: ordinal not in range(128)'

in the sublime text 3 console when trying to print a non-ascii character. I'm using Anaconda Python Builder to build the system. Building the system with the built-in “python” runs perfectly (i.e. prints out non-ascii characters fine) and also running the script from the terminal works fine (i'm running the script on Mac OS Sierra).

I assume the problem must have something to do with the Anaconda Python Builder and I thought adding the default encoding to the Anaconda.sublime-settings might help, but it doesn’t :-( Here is my anaconda user settings file:

{ "python_interpreter": "/usr/local/bin/python3.6", "anaconda_linting": false, "pep8": false, "default_encoding": "UTF-8" }

I would very much appreciate if you could help me along in this matter as I’m searching for a solution for two days now without success :-(

Thank you! Chris


回答1:


Alright, I found a way to do it:

  • Install this plugin: https://packagecontrol.io/packages/Environment%20Settings

  • Change the user settings for that EnvironmentSettings plugin to look like this:

    { "env": { "Darwin": { "LC_ALL": "en_US.UTF-8" } } }



来源:https://stackoverflow.com/questions/42648808/unicode-encode-error-in-sublime-text-3-console

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!