Sunday, January 10, 2010

fix "no module named readline" on windows

I tried to download android source code by following instructions in this article: Using Repo and Git. Because I'm working with cygwin on windows, the readline module isn't available. The repo script failed to run and compained "no module named readline".
Luckily, the Ipython project provides an alternative readline module named pyreadline that can be used on windows and mac osx.
To install it:
1. Download pyreadline for windows.
2. unzip the setup file.
3. Copy PURELIB/readline.py and PURELIB/pyreadline to $(python_installation_folder)/Lib

After it's done, the repo script can run successfully.


Update: In order not to get the python installation folder polluted, we can create a directory for all manually installed python modules. And set PYTHONPATH environment variable to this directory so that modules installed here can be loaded.

8 comments:

Anonymous said...

Thank you. I was trying to use the CalDAVClientLibrary for calendar server and was getting the 'no module named readline' error.

I followed a slightly different set of instructions. I had used ActivePython as my python installation and all I had to do was
"easy_install pyreadline".

Unknown said...

Thanks for you complementary information. I think your way of using easy_install is an "easier" way to do. And my is "cleaner". :)

knucKles said...

You just saved my Bachelor's thesis! :) Thanks a bunch!!!

Clare said...

Oh thankyouthankyouthankyou, I was wrestling with this forever!

Anonymous said...

The activePython process helped me lot. I'm new to Android development and fighting with pyreadline scripts, with limited knowledge on Python. Appreciate your help.

Toan Nguyen said...

Many thanks,

I followed all above steps and it worked as my expectation

Toan Nguyen said...

Many thanks,

I followed all above steps and it works fine

Thanks, Toan

Anonymous said...

I am getting following error.. Please help me

File "c:/Documents and Settings/Sakshara/bin/repo", line 91, in ?
import readline
File "c:\Python24\lib\readline.py", line 5, in ?
from pyreadline.rlmain import Readline
File "c:\Python24\lib\pyreadline\__init__.py", line 9, in ?
import unicode_helper, logger, clipboard, lineeditor, modes, console
File "c:\Python24\lib\pyreadline\modes\__init__.py", line 2, in ?
import emacs,notemacs,vi
File "c:\Python24\lib\pyreadline\modes\emacs.py", line 15, in ?
import basemode
File "c:\Python24\lib\pyreadline\modes\basemode.py", line 12, in ?
from pyreadline.keysyms.common import make_KeyPress_from_keydescr
File "c:\Python24\lib\pyreadline\keysyms\__init__.py", line 20, in ?
raise ImportError(u"Could not import keysym for local pythonversion", x)
mportError: (u'Could not import keysym for local pythonversion', )