相关疑难解决方法(0)

在python shell中按箭头键时看到转义字符

在像交互式python shell这样的shell中,你通常可以使用箭头键在当前行中移动或获取以前的命令(使用向上箭头)等.

但是在我进入另一台机器并从python那里开始之后,我会得到以下会话:

>>> import os 
>>> ^[[A    
Run Code Online (Sandbox Code Playgroud)

最后一个角色来自向上箭头.或者,使用左箭头:

>>> impor^[[D
Run Code Online (Sandbox Code Playgroud)

我怎样才能解决这个问题?

在常规bash中,箭头键工作正常.奇怪的行为只是在交互式python(或perl等)shell中.

python ssh shell arrow-keys

175
推荐指数
13
解决办法
6万
查看次数

如何在python解释器shell中重复最后一个命令?

如何重复上一个命令?通常的键:Up,Ctrl + Up,Alt-p不起作用.他们产生荒谬的人物.

(ve)[kakarukeys@localhost ve]$ python
Python 2.6.6 (r266:84292, Nov 15 2010, 21:48:32) 
[GCC 4.4.4 20100630 (Red Hat 4.4.4-10)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print "hello world"
hello world
>>> ^[[A
  File "<stdin>", line 1
    ^
SyntaxError: invalid syntax
>>> ^[[1;5A
  File "<stdin>", line 1
    [1;5A
    ^
SyntaxError: invalid syntax
>>> ^[p
  File "<stdin>", line 1
    p
    ^
SyntaxError: invalid syntax
>>> 
Run Code Online (Sandbox Code Playgroud)

python shell interpreter virtualenv python-idle

122
推荐指数
8
解决办法
15万
查看次数

ipython抱怨readline

当我在我的osx上安装ipython并运行它时,我收到以下警告:

 /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/
 site-packages/IPython/utils/rlineimpl.py:96:
 RuntimeWarning: Leopard libedit detected - readline will not be wel
 behaved including some crashes on tab completion, and incorrect
 history navigation. It is highly recommended that you install
 readline, which is easy_installable with: 'easy_install readline'
Run Code Online (Sandbox Code Playgroud)

我已经安装了readline,并且不使用最初安装的系统python /Library/Frameworks/Python.framework/Versions/2.7/bin/python$./usr/bin/python版本2.7 的要点如下所示

uname -a
Darwin macbook.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun  7 
16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386

$sudo pip install readline ipython

$ipython --version
0.11

$/usr/bin/python --version # 
Python 2.7.1 

$which python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
Run Code Online (Sandbox Code Playgroud)

我已经阅读了Python sys.path修改中无法正常工作的问题 …

python

26
推荐指数
1
解决办法
9694
查看次数

标签 统计

python ×3

shell ×2

arrow-keys ×1

interpreter ×1

python-idle ×1

ssh ×1

virtualenv ×1