I am trying to get a prompt that will ask for my password but when I try to call getpass.getpass()
it just freezes. I am running on Windows 7 64 bit using Pytho
getpass()
will freeze if python is unable to read properly from standard input.
This can happen on e.g. some Windows terminals, such as using git bash.
You can use the sys
module to detect if this will happen, to avoid hanging:
import getpass
import sys
# ...
if not sys.stdin.isatty():
# notify user that they have a bad terminal
# perhaps if os.name == 'nt': , prompt them to use winpty?
return
else:
password = getpass.getpass()
# ...