9

I am using Python 3.7 and I need to import termios to mask a password input. But I am unable to find it on https://pypi.org/

import sys, tty, termios

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import sys, tty, termios
  File "C:\Python37\lib\tty.py", line 5, in <module>
    from termios import *
ModuleNotFoundError: No module named 'termios'
Salek
  • 449
  • 1
  • 10
  • 19
saiki68
  • 91
  • 1
  • 1
  • 4

2 Answers2

15

https://docs.python.org/3/library/tty.html says:

Because it requires the termios module, it will work only on Unix.

i.e. there is no termios for Windows.

Adrian W
  • 4,563
  • 11
  • 38
  • 52
  • any idea on what to use instead of termios for windows. I need it for masking user input password. – saiki68 Aug 28 '18 at 19:19
  • [Getting command-line password input in Python](https://stackoverflow.com/a/19853787/2311167) – Adrian W Aug 28 '18 at 21:29
  • what about linux. i am getting the same error on cent0s 7 – munish Jun 09 '19 at 09:50
  • If you follow the link to [termios](https://docs.python.org/3/library/termios.html#module-termios) from the tty doc above, it says: _It is only available for those Unix versions that support POSIX termios style tty I/O control configured during installation_. So, Linux in general should be no problem. Just tried in Debian and the `tty` and `termios` modules are available for both Python2 and 3. I don't have any experience with CentOS. So, I can't help much with that. – Adrian W Jun 09 '19 at 12:35
0

In my case there was an unnecessary hint from VS Code asking for this import however as said in this thread it does not work on windows environment.

In my case it could be removed without issue.

Connor Willoughby
  • 86
  • 1
  • 1
  • 10