On 06/15/2014 03:12 PM, Evan Carter wrote:
Thank you for the reply, Adrian. I do not find PYTHONIOENCODING in
either environment. Could it be the SPYDER_ENCODING environment variable
that's causing the behavior?
Running [(k,v) for k, v in os.environ.items() if 'utf' in v.lower() or
'ascii' in v.lower()] in Spyder gives me
[('SPYDER_ENCODING', 'UTF-8')]
while when I run the same command from a Python shell created from the
terminal I get
[('LANG', 'en_US.UTF-8')]
I know from the Postgres mailing lists that OS X has some non-standard
ways of working with locales/encoding. I do not use OS X enough to
really understand what is going on. I can point to others that have more
practical experience in this area, so:
http://blog.remibergsma.com/2012/07/10/setting-locales-correctly-on-mac-osx-terminal-application/
or the suggestions from the first link I sent:
"
So typing export PYTHONIOENCODING=utf-8 prior to invoking the Python
interpreter does the trick, or you could just add this setting to your
environment file: ~/.MacOSX/environment.plist.
As the other commenters have noted, in Python 2 you can print things of
class str directly to the terminal (which are bytestrings) but things of
class unicode need to be converted to bytestrings (str) before they can
be printed. The easiest way to do this is
myunicodestring.encode("utf-8") but if you want to be able to say “print
myunicodestring” without encoding first in the interactive shell, you
can try putting export LC_CTYPE=en_US.utf-8 in your .bash_profile, just
so that Python knows that Terminal.app wants its input (Python’s output)
to be in UTF-8. I think newer versions of Terminal do this automatically
(10.6), but older ones did not.
"
Whatever method you choose it would seem you need to give OS X an assist
in making the correct choice. From the looks of it Anaconda does this by
setting the SPYDER_ENCODING, my guess in its version of the Python
startup file.
--
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.