@@ -11,6 +11,16 @@ import { existsSync } from "fs";
1111import { homedir } from "os" ;
1212import { 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