我正在尝试通过python文件配置WAS管理控制台属性,但收到以下错误:
WASX7017E: Exception received while running file "ConfigureWASMain.py"; exception information: com.ibm.bsf.BSFException: exception from Jython:
Traceback (innermost last):
File "<string>", line 49, in ?
File "/opt/WebSphere7/64bit/optionalLibraries/jython/Lib/javaos.py", line 137, in __getitem__
File "/opt/WebSphere7/64bit/optionalLibraries/jython/Lib/UserDict.py", line 14, in __getitem__
KeyError: BASE_DIR
我的python文件我有以下代码:
import os
import sys
from java.util import Hashtable
from java.util import Properties
from java.io import FileInputStream
sys.path.append(os.environ["BASE_DIR"]) //Line 49
有人请帮我解决此错误。
答案 0 :(得分:0)
您没有设置环境变量BASE_DIR
。如果您使用bash,请执行
export BASE_DIR=/path/to/whatever
运行python代码之前(在同一个终端窗口中)
如果用户
未定义BASE_DIR
,您还应该假设合理的默认值
sys.path.append(os.environ.get("BASE_DIR","/some/default/path"))