Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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).

like image 516
Alon Avatar asked Aug 31 '25 00:08

Alon


1 Answers

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.

like image 75
VonC Avatar answered Sep 03 '25 15:09

VonC