There are three things that you need to get this to work:
your OS needs readline; that is provided by default by Centos;
you also need the readline development libraries; that is not
provided by default;
you need to have readline support turned on in the Python build.
The readline module is not necessary for it, but it will be installed as
part of the standard library. You shouldn’t need to use pip to install
So you don’t need to do anything for #1 unless you are using some really
strange Linux setup. But if arrow keys work in the bash shell, then you
have readline installed.
Next you need the readline-devel package. You need to install that with
your distros’ package manager, which I think is yum. Try this:
yum install readline-devel
or maybe readline-dev.
Then you can build Python from source. As far as I know, by default
readline support is enabled, so you shouldn’t need to do anything to
turn it on.
If you build Python from source before installing readline-devel, it
won’t be able to link to the appropriate readline libraries and so it
won’t support arrow keys. Installing the readline module won’t fix that.
And installing readline with pip shouldn’t be necessary. It should be
included in the stdlib of the interpreter you build.