From 6920afeb5edadf836a7f7da30bba6efbb6380f05 Mon Sep 17 00:00:00 2001 From: Zhou Wei <1183042833@qq.com> Date: Tue, 12 Oct 2021 17:32:59 +0800 Subject: [PATCH] fix windows bug that python virtual env can't find python executable (#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 4fd7dc0d37f..c36213282c5 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