From a7fadce82fe7b660af40a869a096fd617da468db Mon Sep 17 00:00:00 2001 From: Zhou Wei <52485244+zhouwei25@users.noreply.github.com> Date: Thu, 17 Sep 2020 14:10:48 +0800 Subject: [PATCH] fix dll load bug on windows from python3.8 (#27324) --- python/paddle/fluid/core.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/python/paddle/fluid/core.py b/python/paddle/fluid/core.py index a05aa3b0a8..2e3bb6b002 100644 --- a/python/paddle/fluid/core.py +++ b/python/paddle/fluid/core.py @@ -39,6 +39,11 @@ try: third_lib_path = current_path + os.sep + '..' + os.sep + 'libs' os.environ['path'] = third_lib_path + ';' + os.environ['path'] sys.path.insert(0, third_lib_path) + # Note: from python3.8, PATH will not take effect + # https://github.com/python/cpython/pull/12302 + # Use add_dll_directory to specify dll resolution path + if sys.version_info[:2] >= (3, 8): + os.add_dll_directory(third_lib_path) except ImportError as e: from .. import compat as cpt -- GitLab