Skip to content

Commit 4ffd8c8

Browse files
committed
fix #979
1 parent 8cf078e commit 4ffd8c8

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/client/providers/setInterpreterProvider.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ function getSearchPaths(): Promise<string[]> {
2929
const lookupParentDirectories = [process.env['PROGRAMFILES'], process.env['PROGRAMFILES(X86)'],
3030
localAppData, appData,
3131
process.env['SystemDrive']];
32+
lookupParentDirectories.push(path.join(process.env['SystemDrive'], 'Python'));
3233
if (appData) {
3334
lookupParentDirectories.push(path.join(localAppData, 'Programs'));
3435
}
@@ -144,7 +145,18 @@ function suggestionsFromKnownPaths(): Promise<PythonPathSuggestion[]> {
144145
return lookForInterpretersInPath(validatedPath);
145146
});
146147
});
147-
return Promise.all<string[]>(promises).then(listOfInterpreters => {
148+
const currentPythonInterpreter = utils.execPythonFile("python", ["-c", "import sys;print(sys.executable)"], __dirname)
149+
.then(stdout => {
150+
if (stdout.length === 0) {
151+
return [] as string[];
152+
}
153+
let lines = stdout.split(/\r?\n/g).filter(line => line.length > 0);
154+
return utils.validatePath(lines[0]).then(p=> [p]);
155+
}).catch(() => {
156+
return [] as string[];
157+
});
158+
159+
return Promise.all<string[]>(promises.concat(currentPythonInterpreter)).then(listOfInterpreters => {
148160
const suggestions: PythonPathSuggestion[] = [];
149161
const interpreters = listOfInterpreters.reduce((previous, current) => previous.concat(current), []);
150162
interpreters.filter(interpreter => interpreter.length > 0).map(interpreter => {

0 commit comments

Comments
 (0)