From 976f0146512343d24671124bda038b646ee4e4ba Mon Sep 17 00:00:00 2001 From: Zhou Wei <1183042833@qq.com> Date: Thu, 14 Oct 2021 14:50:01 +0800 Subject: [PATCH] fix windows bug that python virtual env can't find python executable (#36227) (#36370) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ATT,cherry-pick #36227 --- python/paddle/dataset/image.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/python/paddle/dataset/image.py b/python/paddle/dataset/image.py index 4fd7dc0d37..c36213282c 100644 --- a/python/paddle/dataset/image.py +++ b/python/paddle/dataset/image.py @@ -39,10 +39,12 @@ import numpy as np if six.PY3: import subprocess import sys - if sys.platform == 'win32': - interpreter = sys.exec_prefix + "\\" + "python.exe" - else: - interpreter = sys.executable + import os + interpreter = sys.executable + # Note(zhouwei): if use Python/C 'PyRun_SimpleString', 'sys.executable' + # will be the C++ execubable on Windows + if sys.platform == 'win32' and 'python.exe' not in interpreter: + interpreter = sys.exec_prefix + os.sep + 'python.exe' import_cv2_proc = subprocess.Popen( [interpreter, "-c", "import cv2"], stdout=subprocess.PIPE, -- GitLab