“GetPassWarning: Can not control echo on the terminal” when running from IDLE

When I run this code:

import getpass

p = getpass.getpass(prompt='digite a senhan')
if p == '12345':
    print('YO Paul')
else:
    print('BRHHH')
print('O seu input foi:', p) # p = seu input

I got this warning:

Warning (from warnings module):
   File "/usr/lib/python3.4/getpass.py", line 63
    passwd = fallback_getpass(prompt, stream)
GetPassWarning: Can not control echo on the terminal. Warning: Password input may be echoed.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Use an actual terminal — that is, an environment where stdin, stdout and stderr are connected to /dev/tty, or another PTY-compliant device.

The IDLE REPL does not meet this requirement.

Method 2

Run your code in terminal, instead of the IDE. you will see that there is no more warning there.
To run your code, enter this command in terminal:

python3 your_program.py

Method 3

Rather than deal with changing the current working directory in a terminal that has not started Python (which would mean you type something like python3 script.py–and it will fail unless the current working directory is already specified), start Python in your terminal and run this one-line command:

exec(open('C:folderscript.py').read())

where you change the path string 'C:folderscript.py' to match wherever your file is located on disk (the string does need to be specified with quotes).

Method 4

use cmd ie. command prompt and then run the file in it.

like:

python abc.py


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x