On 06/16/2014 09:30 PM, Evan Carter wrote:
You are right that Spyder is messing with the encoding in its
sitecustomize.py
<https://code.google.com/p/spyderlib/source/browse/spyderlib/widgets/externalshell/sitecustomize.py>:

|encoding = None
try:
     import locale
except ImportError:
     pass
else:
     loc = locale.getdefaultlocale()
     if loc[1]:
         encoding = loc[1]

if encoding is None:
     encoding = "UTF-8"

try:
     sys.setdefaultencoding(encoding)
     os.environ['SPYDER_ENCODING'] = encoding
except AttributeError:
     # Python 3
     pass|

If I am so bold as to add |encoding = "ascii"| then
|sys.getdefaultencoding()| does indeed give 'ascii' when run from the
console, but I don't know what the consequences will be of messing with
the encoding for all of Spyder. I'd like to change the encoding only for
the Python interpreter in the console, not the Python environment in
which Spyder is running. Unfortunately, adding
|os.environ['SPYDER_ENCODING'] = 'ascii'| doesn't work: the environment
variable stays set but |sys.getdefaultencoding()| still gives |"UTF-8"|.


Some Googling seems to indicate this SO question has the answer:

http://stackoverflow.com/questions/7165108/in-osx-lion-lang-is-not-set-to-utf8-how-fix/8161863#8161863

Try adding or editing the ~/.profile file for it to correctly export your locale settings upon initiating a new session.

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

These two lines added to the file should suffice to set the locale [replace en_US for your desired locale, and check beforehand that it is indeed installed on your system (locale -a)].

After that, you can start a new session and check using locale:


If that does not work, I would say this is question for some OS X experts, of which I am not.



--
Adrian Klaver
[email protected]

--
You received this message because you are subscribed to the Google Groups 
"spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/spyderlib.
For more options, visit https://groups.google.com/d/optout.

Reply via email to