Skip to content

Commit dcc7464

Browse files
committed
Ensure system Python has the highest priority
1 parent 6ffb731 commit dcc7464

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pioinstaller/python.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,12 @@ def find_compatible_pythons(
179179
for p in ignore_pythons or []:
180180
ignore_list.extend(glob.glob(p))
181181
exenames = [
182-
# "python3.11",
182+
"python3", # system Python
183+
"python3.11",
183184
"python3.10",
184185
"python3.9",
185186
"python3.8",
186187
"python3.7",
187-
"python3",
188188
"python",
189189
]
190190
if util.IS_WINDOWS:
@@ -196,8 +196,12 @@ def find_compatible_pythons(
196196
if not os.path.isfile(os.path.join(path, exe)):
197197
continue
198198
candidates.append(os.path.join(path, exe))
199-
if sys.executable not in candidates:
200-
candidates.insert(0, sys.executable)
199+
200+
if sys.executable in candidates:
201+
candidates.remove(sys.executable)
202+
# put current Python to the top of list
203+
candidates.insert(0, sys.executable)
204+
201205
result = []
202206
for item in candidates:
203207
if item in ignore_list:

0 commit comments

Comments
 (0)