Dylan Murphy Dylan Murphy - 1 year ago 338
Python Question

Getpass input Python 3

I am trying to create a password input. I am aware of

but when I put it into my idle it through up an error saying 'password may be echoed' which it was.

My code:

import getpass

p = getpass.getpass()

print("You entered:") + p

This may not work as I am using Python 3.2.3

Answer Source

From the getpass documentation:

Note If you call getpass from within IDLE, the input may be done in the terminal you launched IDLE from rather than the idle window itself.

And also:

If echo free input is unavailable getpass() falls back to printing a warning message to stream and reading from sys.stdin and issuing a GetPassWarning.

So probably you just don't have a echo free input available in your IDLE environment (e.g., you didn't start it from a shell).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download