简体   繁体   中英

Arrow keys not working in python shell on virtualenv on mac osx

So I go into my python virtual environment and the arrow keys, instead of doing what they're supposed to be doing, are creating these things: ^[[D^[[C

It actually happend outside a virtual environment as well, but I fixed it there. Still doesn't work int the virutalenv though.

A bit of googling & stack overflow searching found that it has to do with the fact that upgrading to OSX 10.12 (Sierra) seems to have messed up python's readline. These answers showed me how to fix it outside the virtualenv (which worked):

Arrow keys no longer work in Python shell after upgrading Mac OS to Sierra

ipython complaining about readline

However it still doesn't work inside the virtualenv. I tried pip installing readline and easy_installing readline, but none of it worked.

Thanks in advance for your help.

I'm on High Sierra (10.13) but having the same issue. The following worked for me (you will need HomeBrew though). From your virtual env:

brew install readline
export CFLAGS='-I/usr/local/opt/readline/include -L/usr/local/opt/readline/lib'
pip install readline

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM