I went ahead and wrote the small snippet below based on @Carlos Cordoba comment that since Spyder is based in PyQt, you have that package for sure :
def prompt_password(user):
"""
Parameters
----------
user : user name
Returns
-------
text : user input password
"""
from PyQt5.QtWidgets import QInputDialog, QLineEdit, QApplication
from PyQt5.QtCore import QCoreApplication
# Let's avoid to crash Qt-based dev environment (Spyder...)
app = QCoreApplication.instance()
if app is None:
app = QApplication([])
text, ok = QInputDialog.getText(
None,
"Credential",
"user {}:".format(user),
QLineEdit.Password)
if ok and text:
return text
raise ValueError("Must specify a valid password")