Question: I'm using ipython

Inside the python shell, when I press up instead of showing the last command, it prints 

```
^[[A

```

also CTRL-[keys] are fubar. CTRL-p prints

```
^P

```

Everything is normal under terminal\bash

My guess is that it is an encoding problem. I'd like to either enable the full encoding in ipython or changer the encoding of the shell which runs ipython.

Or any other helpful information is welcome

Answer: 
First, you can try

```
pip install readline

```

Also, please see whether you have `libncurses5-dev` or the equivalent.
This worked for me (using OSX and pyenv):

```
CFLAGS="-I$(brew --prefix readline)/include -I$(brew --prefix openssl)/include -I$(xcrun --show-sdk-path)/usr/include" \
LDFLAGS="-L$(brew --prefix readline)/lib -L$(brew --prefix openssl)/lib" \
PYTHON_CONFIGURE_OPTS=--enable-unicode=ucs2 \
pyenv install -v 2.7.11

```

Source: <https://medium.com/@pimterry/setting-up-pyenv-on-os-x-with-homebrew-56c7541fd331#.urbdkrc9l>