Skip to content

Commit 6920afe

Browse files
authored
fix windows bug that python virtual env can't find python executable (#36227)
1 parent 40cfe7b commit 6920afe

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

python/paddle/dataset/image.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@
3939
if six.PY3:
4040
import subprocess
4141
import sys
42-
if sys.platform == 'win32':
43-
interpreter = sys.exec_prefix + "\\" + "python.exe"
44-
else:
45-
interpreter = sys.executable
42+
import os
43+
interpreter = sys.executable
44+
# Note(zhouwei): if use Python/C 'PyRun_SimpleString', 'sys.executable'
45+
# will be the C++ execubable on Windows
46+
if sys.platform == 'win32' and 'python.exe' not in interpreter:
47+
interpreter = sys.exec_prefix + os.sep + 'python.exe'
4648
import_cv2_proc = subprocess.Popen(
4749
[interpreter, "-c", "import cv2"],
4850
stdout=subprocess.PIPE,

0 commit comments

Comments
 (0)