Python Interactive Interpreter always returns “Invalid syntax” on Windows

前端 未结 5 1580
迷失自我
迷失自我 2020-12-16 04:23

I\'ve encountered an extremely confusing problem. Whatever I type into the Python interpreter returns \"Invalid Syntax\". See examples below. I\'ve tried fooling around w

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-16 05:05

    There is a known problem when running Python interactively and unbuffered, which is scheduled for fixing in 3.2 - and may be backported to older versions, see http://bugs.python.org/issue11098

    The nasty thing is, one may be using unbuffered I/O without realising it. In my case (Python 2.5.4 (r254:67916)), I had some time ago set an environment variable such that Python would always run unbuffered (on Windows, this is PYTHONUNBUFFERED=YES, or whatever non-empty string substituted for YES) and then forgot about it. Removing the env.var. solved the problem for me.

    So it may be worthwhile checking for this environment variable. It's not set by default.

提交回复
热议问题