Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python3 messes up terminal

I'm in Mac OS X 10.10, using python3 installed using Macports.

There is something really strange going on when I start the interactive python3 shell. When starting python3 and runs anything (even non-syntactical commands), something happens to the terminal such that

  1. I cannot see any newlines while hitting Enter
  2. Anything I write doesn't show while typing, but will still be executed when hitting Enter.

This problem persists in the underlying bash shell, after closing the python3 shell (using e.g. Ctrl-D). What makes this even "funnier" is that starting regular python afterwards (version 2.7 by the way), the problem solves itself – the terminal behaves as it should.

Has anyone seen this, has any suggestion what might have happened and hopefully knows a way to resolve this? Thank you.

like image 989
gustafbstrom Avatar asked Sep 09 '15 09:09

gustafbstrom


1 Answers

Yep, I see this problem too using python3.5 on Mac OS X 10.10.

This seems to be a bug with the python3 interactive shell - it disables echo for your terminal and does not enable it when you exit(). To fix your terminal, run this command at the bash prompt.

stty echo

Credit goes to this post.

UPDATE:
This bug is tracked here: https://trac.macports.org/ticket/48807
The permanent fix is to install the port py35-readline.

sudo port install py35-readline
like image 93
amath Avatar answered Sep 20 '22 19:09

amath