[OT] - what happens to the cmd module in python 2.3.5 on windows?

Hi,

Sorry for the off-topic request, but I can't find anything by googling and I'm sure to talk to a crowd of expert Pythoneers, so...

I'm building a CLI+GUI app for data analysis using wxpython and matplotlib for the GUI, and the Cmd standard Python module for the command line. The cli and the gui run in two separate threads.

On Debian GNU/Linux the application works perfectly. I'm trying to get it working on Windows too. I'd like it to be able to work with the Enthought python distribution on Windows, that already includes 90% of the external libraries (scipy, numarray, wxpython etc.) I need, so people don't have to install a bazillion dependencies one by one to get it working -just a few must be downloaded in addition.

This distribution ships Python 2.3.5.

Now, on windows the GUI thread starts apparently correctly, but the CLI doesn't work and stops with the following error:

Exception in thread Thread-1:Traceback (most recent call last):
   File "C:\Python23\lib\threading.py", line 442, in __bootstrap
     self.run()
   File "hooke.py", line 57, in run
     cli.cmdloop()
   File "C:\Python23\lib\cmd.py", line 109, in cmdloop
     self.preloop()
   File "C:\Python23\lib\cmd.py", line 152, in preloop
     import readline
   File "C:\Python23\lib\site-packages\readline\__init__.py", line 1, in ?
     from PyReadline import *
   File "C:\Python23\lib\site-packages\readline\PyReadline.py", line 1091, in ?
     rl = Readline()
   File "C:\Python23\lib\site-packages\readline\PyReadline.py", line 46, in __ini
t__
     self.emacs_editing_mode(None)
   File "C:\Python23\lib\site-packages\readline\PyReadline.py", line 1008, in ema
cs_editing_mode
     self._bind_key('"%s"' % chr(c), self.self_insert)
   File "C:\Python23\lib\site-packages\readline\PyReadline.py", line 1000, in _bi
nd_key
     keyinfo = key_text_to_keyinfo(key)
   File "C:\Python23\lib\site-packages\readline\keysyms.py", line 101, in key_tex
t_to_keyinfo
     return keyseq_to_keyinfo(keytext[1:-1])
   File "C:\Python23\lib\site-packages\readline\keysyms.py", line 163, in keyseq_
to_keyinfo
     res.append(char_to_keyinfo(keyseq[0], control, meta, shift))
   File "C:\Python23\lib\site-packages\readline\keysyms.py", line 111, in char_to
_keyinfo
     raise ValueError, 'bad key'
ValueError: bad key

I really can't understand how to patch the thing here. Any suggestion?

Thanks again for your patience,
m.

···

--
Massimo Sandal
University of Bologna
Department of Biochemistry "G.Moruzzi"

snail mail:
Via Irnerio 48, 40126 Bologna, Italy

email:
massimo.sandal@unibo.it

tel: +39-051-2094388
fax: +39-051-2094387

Hi Massimo,

Sorry for the off-topic request, but I can't find anything by googling and I'm sure to talk to a crowd of expert Pythoneers, so...

I really don't want to seem agressive, but I think you might be more
likely to get help by posting to another list.

If you know it's off-topic then it remains off-topic -- even if you know
that knowledgable people are reading it. What you're doing now, by
cross-posting an off-topic question to two lists of knowledgable people,
is the same as posting a question about how to do some generic thing in
C to linux-kernel. The recipients might well know the answer, but I
doubt they'd welcome the question!

Good luck!

-- Mike

···

On Fri, Apr 21, 2006 at 08:19:35PM +0200, massimo sandal wrote:

Hi,

Sorry for the off-topic request, but I can't find anything by googling
and I'm sure to talk to a crowd of expert Pythoneers, so...

Even if you get an answer, it will still be off-topic. :slight_smile:

I'm building a CLI+GUI app for data analysis using wxpython and
matplotlib for the GUI, and the Cmd standard Python module for the
command line. The cli and the gui run in two separate threads.

On Debian GNU/Linux the application works perfectly. I'm trying to get
it working on Windows too. I'd like it to be able to work with the
Enthought python distribution on Windows, that already includes 90% of
the external libraries (scipy, numarray, wxpython etc.) I need, so
people don't have to install a bazillion dependencies one by one to get
it working -just a few must be downloaded in addition.

This distribution ships Python 2.3.5.

Python 2.3.5 seems to be a bit outdated: :wink:
http://www.python.org/download/releases/2.3.5/index

Now, on windows the GUI thread starts apparently correctly, but the CLI
doesn't work and stops with the following error:

Exception in thread Thread-1:Traceback (most recent call last):
   File "C:\Python23\lib\threading.py", line 442, in __bootstrap
     self.run()
   File "hooke.py", line 57, in run
     cli.cmdloop()
   File "C:\Python23\lib\cmd.py", line 109, in cmdloop
     self.preloop()
   File "C:\Python23\lib\cmd.py", line 152, in preloop
     import readline
   File "C:\Python23\lib\site-packages\readline\__init__.py", line 1, in ?
     from PyReadline import *
   File "C:\Python23\lib\site-packages\readline\PyReadline.py", line
1091, in ?
     rl = Readline()
   File "C:\Python23\lib\site-packages\readline\PyReadline.py", line 46,
in __ini
t__
     self.emacs_editing_mode(None)
   File "C:\Python23\lib\site-packages\readline\PyReadline.py", line
1008, in ema
cs_editing_mode
     self._bind_key('"%s"' % chr(c), self.self_insert)
   File "C:\Python23\lib\site-packages\readline\PyReadline.py", line
1000, in _bi
nd_key
     keyinfo = key_text_to_keyinfo(key)
   File "C:\Python23\lib\site-packages\readline\keysyms.py", line 101,
in key_tex
t_to_keyinfo
     return keyseq_to_keyinfo(keytext[1:-1])
   File "C:\Python23\lib\site-packages\readline\keysyms.py", line 163,
in keyseq_
to_keyinfo
     res.append(char_to_keyinfo(keyseq[0], control, meta, shift))
   File "C:\Python23\lib\site-packages\readline\keysyms.py", line 111,
in char_to
_keyinfo
     raise ValueError, 'bad key'
ValueError: bad key

I really can't understand how to patch the thing here. Any suggestion?

To me, it looks like some mismatch between cmd and readline.
Try again with a newer version?

Harald Stürzebecher

···

2006/4/21, massimo sandal <massimo.sandal@unibo.it>:

I really don't want to seem agressive, but I think you might be more
likely to get help by posting to another list.

I agree with you, and I'm really sorry for my own lack of politeness. I just felt lost at the end of the work day, and I thought there could be a quick answere here (or there). I agree it was not the best idea I could have. I won't repeat the error.

Anyway, just for the sake of other people googling for this... I looked harder and I found what it is. the problem is that (at least in older Python versions) the readline module on windows is broken, and the cmd module (that relies on readline) doesn't work. There is a (third party) installable version of readline for windows that can be downloaded from the net.

Thanks,
Massimo

···

--
Massimo Sandal
University of Bologna
Department of Biochemistry "G.Moruzzi"

snail mail:
Via Irnerio 48, 40126 Bologna, Italy

email:
massimo.sandal@unibo.it

tel: +39-051-2094388
fax: +39-051-2094387