I remember when I would get this error -- seemed like the kiss of death as far as trying to maneuver once I got a shell.  I'd flounder around, trying to figure out how to accomplish the task at hand but this issue would severely limit my ability.

Somewhere along the way, I discovered the cause -- you don't have a TTY.   What do you do?

First things first -- once you get your shell, hit the enter key a few times.  I don't know why but it seems like the first carriage return has garbage sitting behind it and hitting the enter key flushes that out.  

Next, type the following:

python -c 'import pty; pty.spawn("/bin/sh")'

(pty = psuedo tty)

As an added bonus, type this as well:

export TERM=xterm

Now you have a fully functional shell.  Life is grand.