[IPython-user] Cygwin - stdout encoding problem

Jörgen Stenarson jorgen.stenarson@bostream...
Wed Jan 28 14:36:01 CST 2009


Standaert Arnout skrev:
> Hello,
> 
> Just installed ipython 0.9.1 on Python 2.5.2 on a Windows XP system. I intend to use it under Cygwin's Bash shell.
> Without installing pyreadline, everything works OK. But when I install pyreadline (want colors!), ipython fails to initialize correctly.
> 
> The problem: in "unicode_helper.py", ipython tries to guess the shell's encoding with the line:
> 
>         pyreadline_codepage=sys.stdout.encoding
> 
> Now, in a Cygwin Bash shell, sys.stdout.encoding is apparently not set, returning a "None" value here. This causes an error further down in the line:
> 
>         return text.decode(pyreadline_codepage, "replace")
> 
> This returns a TypeError and ipython crash dumps...
> 
> Can anyone suggest a solution for this?
> 

I have tried to replicate your problem but I get an ImportError (windll 
library loader is not available in ctypes) when I try to use pyreadline 
under cygwin python 2.5.2.

However have you tried to set pyreadline_codepage to a value that is 
consistent with your console. If you do this at the top of your 
ipy_user_conf.py file this should set pyreadline_codepage to a sensible 
value before it is used.

Example:
import pyreadline.unicode_helper
pyreadline.unicode_helper.pyreadline_codepage = "cp1252"

It also looks like you have an older version of pyreadline. There have 
been changes in this code lately. So you could also try the trunk version.
In the new code if pyreadline_codepage is not set it defaults to ascii
which may not be what you want.

/Jörgen


More information about the IPython-user mailing list