Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #38745
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2013-02-12 04:34 -0800 |
| References | <650d144e-da3d-4ca7-ad3a-49f44ce9cbaa@googlegroups.com> <511a2ac5$0$29988$c3e8da3$5496439d@news.astraweb.com> |
| Message-ID | <9bc96ed6-8cb7-421a-a25a-4a7c9404463a@googlegroups.com> (permalink) |
| Subject | Re: UnicodeEncodeError when not running script from IDE |
| From | Magnus Pettersson <magpettersson@gmail.com> |
Ahh so its the actual printing that makes it error out outside of eclipse because its a different terminal that its printing to. Its the default DOS terminal in windows that runs then i run the script with python.exe and i guess its the same when i run with pythonw.exe just that the terminal window is not opened up, only the pyqt gui in this case. I will try to fix it now when i know what it is :) I never thought about the terminal, last time i had the same problem i just were playing around for hours with unicode encode and decode and all that not-so-fun stuff :) Andrew Berg: Thanks, your crystal ball seems to be right :P On Tuesday, February 12, 2013 12:43:00 PM UTC+1, Steven D'Aprano wrote: > Magnus Pettersson wrote: > > > > > I am using Eclipse to write my python scripts and when i run them from > > > inside eclipse they work fine without errors. > > > > > > But almost in every script that handle some form of special characters > > > like swedish åäö and chinese characters etc > > > > A comment: they are not "special" characters. They're merely not American. > > > > > > > i get Unicode errors when > > > running the script externally with python.exe or pythonw.exe (but the > > > scripts run completely fine from within Eclipse (standard pydev projects, > > > python2.7). I have usually launched the script gui from wihin eclipse > > > because of this error but now i want to get the bottom of this so i dont > > > have to open eclipse everytime i want to run a script! > > > > > > Here is the error i get now when running the script with python.exe: > > > UnicodeEncodeError:'charmap' codec cant encode character u'\u898b' in > > > position 32: character maps to <undefined> > > > > Please show the *complete* traceback, including the line of code that causes > > the exception. > > > > > > > what can i do to fix this? > > > > My guess is that you are trying to print a character which your terminal > > cannot display. My terminal is set to use UTF-8, and so it can display it > > fine: > > > > py> c = u'\u898b' > > py> print(c) > > 見 > > > > > > (or at least it would display fine if the font used had a glyph for that > > character). Why there are still terminals in the world that don't default > > to UTF-8 is beyond me. > > > > If I manually change the terminal's encoding to Western European ISO 8859-1, > > I get some moji-bake: > > > > py> print(c) > > è¦ > > > > > > I can't replicate the exception you give, so I assume it is specific to > > Windows. > > > > > > > > > > -- > > Steven
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
UnicodeEncodeError when not running script from IDE Magnus Pettersson <magpettersson@gmail.com> - 2013-02-12 02:43 -0800
Re: UnicodeEncodeError when not running script from IDE Andrew Berg <bahamutzero8825@gmail.com> - 2013-02-12 05:01 -0600
Re: UnicodeEncodeError when not running script from IDE Magnus Pettersson <magpettersson@gmail.com> - 2013-02-12 06:24 -0800
Re: UnicodeEncodeError when not running script from IDE Peter Otten <__peter__@web.de> - 2013-02-12 15:49 +0100
Re: UnicodeEncodeError when not running script from IDE Magnus Pettersson <magpettersson@gmail.com> - 2013-02-12 07:29 -0800
Re: UnicodeEncodeError when not running script from IDE Peter Otten <__peter__@web.de> - 2013-02-12 16:48 +0100
Re: UnicodeEncodeError when not running script from IDE Dave Angel <davea@davea.name> - 2013-02-12 10:58 -0500
Re: UnicodeEncodeError when not running script from IDE Magnus Pettersson <magpettersson@gmail.com> - 2013-02-12 09:12 -0800
Re: UnicodeEncodeError when not running script from IDE Fabio Zadrozny <fabiofz@gmail.com> - 2013-02-12 18:04 -0200
Re: UnicodeEncodeError when not running script from IDE Dave Angel <davea@davea.name> - 2013-02-12 15:51 -0500
Re: UnicodeEncodeError when not running script from IDE Magnus Pettersson <magpettersson@gmail.com> - 2013-02-12 16:20 -0800
Re: UnicodeEncodeError when not running script from IDE Dave Angel <davea@davea.name> - 2013-02-12 22:51 -0500
Re: UnicodeEncodeError when not running script from IDE Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-13 11:21 +1100
Re: UnicodeEncodeError when not running script from IDE Magnus Pettersson <magpettersson@gmail.com> - 2013-02-12 16:40 -0800
Re: UnicodeEncodeError when not running script from IDE Magnus Pettersson <magpettersson@gmail.com> - 2013-02-12 07:29 -0800
Re: UnicodeEncodeError when not running script from IDE MRAB <python@mrabarnett.plus.com> - 2013-02-12 21:03 +0000
Re: UnicodeEncodeError when not running script from IDE Magnus Pettersson <magpettersson@gmail.com> - 2013-02-12 06:24 -0800
Re: UnicodeEncodeError when not running script from IDE Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-12 22:43 +1100
Re: UnicodeEncodeError when not running script from IDE Magnus Pettersson <magpettersson@gmail.com> - 2013-02-12 04:34 -0800
Re: UnicodeEncodeError when not running script from IDE Terry Reedy <tjreedy@udel.edu> - 2013-02-12 11:07 -0500
csiph-web