Skip to content

Commit 2e39516

Browse files
committed
Don't use Windows Store python
Do not pick the Windows Store python, and clear it from the settings if it was already chosen, as it seems to cause issues on some systems Fixes #127 and #156
1 parent 3761deb commit 2e39516

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/utils/pythonHelper.mts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ import { existsSync } from "fs";
1111
import { homedir } from "os";
1212
import { extensionName } from "../commands/command.mjs";
1313

14+
function checkUnsupportedPython(pythonPath: string): boolean {
15+
// Problems seem to occur on some Windows systems when using the Windows Store Python
16+
// so check for that and don't use it.
17+
if (pythonPath.includes("AppData\\Local\\Microsoft\\WindowsApps")) {
18+
return true;
19+
}
20+
21+
return false;
22+
}
23+
1424
/**
1525
* This function tries to find a python environment to use. It will possible download
1626
* a python environment if it is not found and a download is available. This will
@@ -44,7 +54,7 @@ export default async function findPython(): Promise<string | undefined> {
4454
);
4555
if (pythonPath) {
4656
// check if it actually exists and is a supported version
47-
if (existsSync(pythonPath)) {
57+
if (existsSync(pythonPath) && !checkUnsupportedPython(pythonPath)) {
4858
try {
4959
const version = execSync(`${
5060
process.env.ComSpec === "powershell.exe" ? "&" : ""
@@ -210,7 +220,10 @@ async function findPythonInPythonExtension(): Promise<string | undefined> {
210220
resolved?.version &&
211221
checkPythonVersion(resolved.version.major, resolved.version.minor)
212222
) {
213-
if (resolved.executable.uri) {
223+
if (
224+
resolved.executable.uri &&
225+
!checkUnsupportedPython(resolved.executable.uri.fsPath)
226+
) {
214227
return resolved.executable.uri.fsPath;
215228
} else {
216229
Logger.debug(
@@ -231,7 +244,10 @@ async function findPythonInPythonExtension(): Promise<string | undefined> {
231244
resolved?.version &&
232245
checkPythonVersion(resolved.version.major, resolved.version.minor)
233246
) {
234-
if (resolved.executable.uri) {
247+
if (
248+
resolved.executable.uri &&
249+
!checkUnsupportedPython(resolved.executable.uri.fsPath)
250+
) {
235251
return resolved.executable.uri.fsPath;
236252
} else {
237253
Logger.debug(

0 commit comments

Comments
 (0)