parent
1bf4083dc6
commit
d9642cf757
@ -117,18 +117,23 @@ def _load_lib():
|
|||||||
lib_paths = find_lib_path()
|
lib_paths = find_lib_path()
|
||||||
if len(lib_paths) == 0:
|
if len(lib_paths) == 0:
|
||||||
return None
|
return None
|
||||||
pathBackup = os.environ['PATH']
|
try:
|
||||||
|
pathBackup = os.environ['PATH'].split(os.pathsep)
|
||||||
|
except KeyError:
|
||||||
|
pathBackup = []
|
||||||
lib_success = False
|
lib_success = False
|
||||||
os_error_list = []
|
os_error_list = []
|
||||||
for lib_path in lib_paths:
|
for lib_path in lib_paths:
|
||||||
try:
|
try:
|
||||||
# needed when the lib is linked with non-system-available dependencies
|
# needed when the lib is linked with non-system-available dependencies
|
||||||
os.environ['PATH'] = pathBackup + os.pathsep + os.path.dirname(lib_path)
|
os.environ['PATH'] = os.pathsep.join(pathBackup + [os.path.dirname(lib_path)])
|
||||||
lib = ctypes.cdll.LoadLibrary(lib_path)
|
lib = ctypes.cdll.LoadLibrary(lib_path)
|
||||||
lib_success = True
|
lib_success = True
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
os_error_list.append(str(e))
|
os_error_list.append(str(e))
|
||||||
continue
|
continue
|
||||||
|
finally:
|
||||||
|
os.environ['PATH'] = os.pathsep.join(pathBackup)
|
||||||
if not lib_success:
|
if not lib_success:
|
||||||
libname = os.path.basename(lib_paths[0])
|
libname = os.path.basename(lib_paths[0])
|
||||||
raise XGBoostError(
|
raise XGBoostError(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user