PDA

View Full Version : Enable Readline capability in Python 2.6.1



dorseye
February 20th, 2009, 01:57 AM
Greetings.
I am running a virtual machine Ubuntu Gutsy Gibbon.
It came with Python 2.5 preinstalled, and I'm able to use the "up arrow" (repeat last command entered) in Bash and the 2.5 Python Interpreter.

I installed Python 2.6.1 from source, but in the 2.6.1 interpreter when I hit up arrow to repeat a command all I get is:
>>> ^[[A

I went ahead and ran aptitude and installed the libreadline5-dev using aptitude, then rebuilt from source, and still nothing. Any idea how to resolve this and get the "up arrow" functionality working in my 2.6.1 installation working?

ssam
February 20th, 2009, 11:00 AM
have you tried

import readline

if that works there are a few places you can put to get it imported every time you start the interpreter, see man python for details.

dorseye
February 20th, 2009, 03:37 PM
have you tried

import readline

if that works there are a few places you can put to get it imported every time you start the interpreter, see man python for details.

I have -- no luck with "import readline" either.

imdano
February 20th, 2009, 05:31 PM
Did readline support show up as being on when you ran ./configure the second time? It's possible that the "no" status you got the first time got cached.

dorseye
February 20th, 2009, 08:24 PM
I wondered about the readline-no being cached also, but I did try a new ./configure using --with-readline, and still nothing.

The other thing that is really weird, is that the /usr/Python2.5 and /usr/Python2.6 directories are vastly different, I dont know if I just built it from source totally incorrect?

imdano
February 20th, 2009, 09:56 PM
When you install 2.6 it's going to be missing all the 3rd party libraries you had in 2.5, which might account for some of the differences. I'd take a closer look at your configure output, I remember having an issue where it would ignore a library I just installed even when I explicitly told it to look for it. It started working after I deleted the config.cache file.

casevh
February 21st, 2009, 02:05 AM
You need to install libreadline5-dev.

casevh

dorseye
February 21st, 2009, 03:40 AM
You need to install libreadline5-dev.

casevh

As I said in my first message,

"I went ahead and ran aptitude and installed the libreadline5-dev"

Should I install it a different way?

casevh
February 21st, 2009, 04:58 AM
Sorry, missed that part.

Did you do "make distclean" and "./configure" again?

casevh

dorseye
February 21st, 2009, 07:00 PM
Sorry, missed that part.
Did you do "make distclean" and "./configure" again?
casevh

Now I did:


make distclean
./configure --with-readline
make

And still get:
>>> ^[[A

casevh
February 22nd, 2009, 12:46 AM
Are there any warnings at the end of "make"? This is what I get on my system:

Failed to find the necessary bits to build these modules:
_bsddb bsddb185 dbm
dl gdbm imageop
sunaudiodev

Is readline listed?

Have you verified that the file "readline.h" exists? (Probably in /usr/include/readline/)

casevh