Search code examples
windowspython-2.7git-bashtty

Getting an `stdin is not a tty` error when using python json.tool in git bash


I am using Git Bash on Windows, trying to pretty print JSON output using the command line. Following this answer, I try the following:

$ echo '{"print": "this"}' | python -m json.tool
stdin is not a tty

My Python version is 2.7.15 (Anaconda).

When I try the same using the native Windows cmd, it works correctly (but I want to use Bash).


Solution

  • Would echo '{"print": "this"}' | python.exe -m json.tool works better in a git bash session (adding .exe to python).

    That seems to be a winpty issue, as shown here.