【问题标题】:Not able to import getpass in python无法在python中导入getpass
【发布时间】:2013-10-01 06:09:17
【问题描述】:

我需要从控制台输入用户名和密码。对于我使用的密码

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 有一些问题。 在这方面需要帮助。

【问题讨论】:

  • 你的系统中有/usr/lib/python2.4/getpass.py吗?
  • No /usr/lib/python2.4 只有站点包作为子文件夹
  • 听起来你的 Python 安装坏了——重新安装吧。

标签: python weblogic importerror wlst


【解决方案1】:

参数getpass.getpass() 是在python 2.5 中添加的。查看旧手册,http://docs.python.org/release/2.4/lib/module-getpass.html

【讨论】:

  • 好的,我编辑了,但问题是它无法导入 getpass
【解决方案2】:

有点旧,但您的文件可能名为“getpass.py”

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-11-29
    • 2018-02-13
    • 2010-11-19
    • 2016-05-27
    • 2013-02-17
    • 2016-05-12
    • 2018-11-30
    • 2011-07-04
    相关资源
    最近更新 更多