From fcf94914f03574fe771bd1b3d8200ea6a305fc6c Mon Sep 17 00:00:00 2001 From: Hu Shiwen Date: Sun, 27 Sep 2020 15:07:46 +0800 Subject: [PATCH] fix python 3.8 ctypes dll load with windows --- python/mxnet/base.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/python/mxnet/base.py b/python/mxnet/base.py index 0b4bdf9a97c2..daa33b856dbc 100644 --- a/python/mxnet/base.py +++ b/python/mxnet/base.py @@ -276,7 +276,12 @@ class MXCallbackList(ctypes.Structure): def _load_lib(): """Load library by searching possible path.""" lib_path = libinfo.find_lib_path() - lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_LOCAL) + if sys.version_info >= (3, 8) and os.name == "nt": + # use LOAD_WITH_ALTERED_SEARCH_PATH, For simplicity, let's just fill the numbers. + # pylint: disable=E1123 + lib = ctypes.CDLL(lib_path[0], winmode=0x00000008) + else: + lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_LOCAL) # DMatrix functions lib.MXGetLastError.restype = ctypes.c_char_p return lib