gustafbstrom gustafbstrom - 1 month ago 5
Python Question

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.

Answer

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