From 55c4d5c0e3c3dc9b46fc6034b039685616f5ead7 Mon Sep 17 00:00:00 2001 From: Hu Shiwen Date: Thu, 1 Oct 2020 08:00:09 +0800 Subject: [PATCH] fix python 3.8 ctypes dll load with windows (#19236) --- 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 ca98116e5891..586aeb932bcd 100644 --- a/python/mxnet/base.py +++ b/python/mxnet/base.py @@ -339,7 +339,12 @@ def classproperty(func): 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