我需要从控制台输入用户名和密码。对于我正在使用的密码
password = getpass.getpass('Enter password')
我已经使用了
import getpass
但是得到了
ImportError : no module named getpass
还尝试使用设置pythonpath
export pythonpath=/usr/lib/python2.4/site-packages:/usr/lib/python2.4
代码:
#!/usr/bin/python2.4
import sys
import getpass
WL_USER = raw_input('Enter the username to login to BI EM:')
WL_PASSWD = getpass.getpass('Enter the password:')
HOST_NAME = raw_input('Enter the BI host URL')
WL_PORT = raw_input('Enter the admin port for BI')
错误:
ImportError: no module named getpass
一件重要的事情是我尝试将脚本作为 wlst 脚本运行,即尝试编辑 Mbean 的属性。所以执行过程是这样的: /home/wlserver_10.3/common/bin/wlst.sh test.py
我尝试将脚本执行为 python test.py 它执行得很好。所以看起来 wlst 存在一些问题。 需要这方面的帮助。
参数
getpass.getpass()
是在Python 2.5中添加的。查看旧手册,http://docs.python.org/release/2.4/lib/module-getpass.html
有点旧,但你的文件可能名为“getpass.py”