Every time that I run python
or python3
with an interactive console, the display of the prompt gets out of sync almost immediately after the first or second interaction:
>>> [1,2,3]
>>> [1, 2, 3]
print('hi')
>>> hi
Then, when I exit out of python, this behavior carries over to bash
, with the addition that when you type, nothing appears on the screen, but it will still run. In the following example, I typed date
and then history | tail -n3
:
$ Thu Oct 8 07:55:47 CEST 2015
$ 488 python
489 date
490 history | tail -n3
However, after typing reset
, everything goes back to normal.
Needless to say, this behavior is very annoying. What is the cause, and how can I fix it?
I am on OS X. Using iTerm or built-in Terminal.app both give the same behavior. My python builds are from macports
. This problem is not present with /usr/bin/python
(python 2.7.2, included with OS X).
============================
Edit: If I use zsh
, then python still has problems, but everything works fine in zsh
after I exit out of python.
$TERM
is xterm-256color
in both bash
and zsh
.
s=$(stty -g)
before launching python andstty $s
after, to save and restore the terminal configuration. But it will not help during your python interactive session... – Hyphenexit()
and both yield the same result. – Decoteau$TERM
variable set to (echo $TERM
)? – Bandannasudo port selfupdate
,sudo port upgrade outdated
,python -V
,python3 -V
, and thenecho $BASH_VERSION
and post the output of the last three here. If you haven't switched your default shell to MacPorts's, then follow the instructions here before running these commands. – PondweedPython 2.7.10
Python 3.4.3
4.3.42(1)-release
, and behavior is the same. – DecoteauTERM
manually? Does this problem happen if you don't do that? – Sheeree$TERM
in my profile. Terminal.app and iTerm.app both have settings to declare the terminal type. I have never changed that setting, so I assume thatxterm-256color
is the most popular default. I can also declare asansi
,dtterm
,nsterm
,rxvt
,vt52
,vt100
,vt102
,xterm
, orxterm-16color
. I tried usingansi
andxterm
on Terminal.app and I get the same behavior. – DecoteauTERM
isxterm-256color
out of the box in the built-in Terminal at least on Yosemite. – Ankeny