将Mac OS升级到Sierra后,箭头键不再适用于Python shell

时间:2016-10-01 14:46:59

标签: python macos zsh iterm2 pyenv

我正在使用zsh,iTerm2(3.0.9)和pyenv(1.0.2),并将pyenv global设置为3.5.2。

在Python shell中,上下箭头键用于工作,以访问历史记录中的先前命令。但现在升级到OSX 10.12后,它显示控制字符。例如,向上箭头显示:

^[[A

我已按照Seeing escape characters when pressing the arrow keys in python shell中的建议尝试安装readline,但这没有帮助。我没有PYTHONSTARTUP变量但之前没有使用过,也不确定它与pyenv的交互方式。

7 个答案:

答案 0 :(得分:11)

我有完全相同的问题,这个命令对我有用<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="client_container"> <div class="header"></div> <div class="footer"></div> <img class="big_img" src="http://lorempixel.com/output/people-q-c-300-300-7.jpg"> <div class="button button_animate"></div> </div> <div class="client_container"> <div class="header"></div> <div class="footer"></div> <img class="big_img" src="http://lorempixel.com/output/people-q-c-300-300-7.jpg"> <div class="button button_animate"></div> </div>

此处完全信用:ipython complaining about readline

答案 1 :(得分:8)

我通过从homebrew安装python来解决它:

select 
  psu.package_id,
  p.*,            -- the joined entity
  count(psu.*)    -- the aggregate
from packaged_stock_unit psu
inner join stock_unit su
 on su.id = psu.stock_unit_id
inner join part p
 on p.id = su.part_id
where
 psu.some_value = 1
 and psu.package_id = 1
group by psu.package_id, p.sku;

答案 2 :(得分:3)

这对我有用:

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

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

答案 3 :(得分:0)

我看到了同样的事情,我能够想到的唯一“修复”就是不在我的.zshrc文件中运行pyenv init -命令。然而,这将阻止虚拟环境的运行..所以它不是一个修复,而是一个解决方法,让python shell历史再次工作。

我正在继续寻找,看看是否有一个永久性的解决方案,因为没有它我就没那么高效。

答案 4 :(得分:0)

需要配置python的快捷方式。

在外壳中,运行idle3,然后更新键的缩写:

How to repeat last command in python interpreter shell?

答案 5 :(得分:0)

为我解决的是运行jsphpl提到的步骤(取消链接和安装),然后另外使用brew重新链接python并允许覆盖冲突的文件。

答案 6 :(得分:0)

在使用brew安装的python时,升级XCode或XCode工具(通常是在操作系统升级中发生)可能会发生这种情况。

在这种情况下,您只需要重新安装:

brew reinstall python

如果您需要python 2,请记住现在brew默认为python3,所以您需要:

brew reinstall python2
相关问题