Spyder, IDLE, command line and unicode -- cannot display pi character

302 views
Skip to first unread message

Alchemist45

unread,
Oct 26, 2013, 10:46:07 AM10/26/13
to spyd...@googlegroups.com
I have run across a puzzle to me.  I am not experience in using unicode in python;  I am a self-taught programmer using python, Lazarus, and R primarily.  I have a small program that has a pi character in a dictionary.  I want to print out the character to the console.  My program converts the str to unicode and prints.  I get the expected pi character (utf-8) if I use the IDLE interface or the command line to run the .py program.  If I try to use Spyder to run it I get an decode error about no character available.

Any ideas?


Adrian Klaver

unread,
Oct 26, 2013, 2:27:29 PM10/26/13
to spyd...@googlegroups.com
What is the exact error text?

What is the string you are converting?

>
>

--
Adrian Klaver
adrian...@gmail.com

stone...@gmail.com

unread,
Oct 26, 2013, 5:09:27 PM10/26/13
to spyd...@googlegroups.com
if you try this
````
print("Π")
````

and it answers something like  this :
````
File "C:....\python-3.3.2\lib\encodings\cp1252.py", line 19, in encode
 return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u03a0' in position 0: character maps to <undefined>
````

This is because you are in Windows, and the Spyder Console Character Set  is not in utf-8 (but cp1252/latin-1, for example)

Unfortunately, I don't know how to change that.

Carlos Córdoba

unread,
Oct 31, 2013, 12:21:44 PM10/31/13
to spyd...@googlegroups.com
Thanks for reporting. This seems an error we need to fix before 2.3 is released.

El 26/10/13 16:09, stone...@gmail.com escribió:
--
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 spyderlib+...@googlegroups.com.
To post to this group, send email to spyd...@googlegroups.com.
Visit this group at http://groups.google.com/group/spyderlib.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages