@@ -334,22 +334,27 @@ function getPythonExecutable(pythonPath: string): string {
334334 if ( isValidPythonPath ( pythonPath ) ) {
335335 return pythonPath ;
336336 }
337-
338- // Suffix with 'python' for linux and 'osx ', and 'python.exe' for 'windows'
339- if ( IS_WINDOWS ) {
340- if ( isValidPythonPath ( path . join ( pythonPath , 'python.exe' ) ) ) {
341- return path . join ( pythonPath , 'python.exe' ) ;
342- }
343- if ( isValidPythonPath ( path . join ( pythonPath , 'scripts' , 'python .exe') ) ) {
344- return path . join ( pythonPath , 'scripts' , 'python.exe' ) ;
345- }
346- }
347- else {
348- if ( isValidPythonPath ( path . join ( pythonPath , 'python' ) ) ) {
349- return path . join ( pythonPath , 'python' ) ;
337+ // Keep python right on top, for backwards compatibility
338+ const KnownPythonExecutables = [ 'python' , 'python4' , 'python3.6' , 'python3.5' , 'python3 ', 'python2.7' , 'python2' ] ;
339+
340+ for ( let executableName of KnownPythonExecutables ) {
341+ // Suffix with 'python' for linux and 'osx', and 'python.exe' for 'windows'
342+ if ( IS_WINDOWS ) {
343+ executableName = executableName + ' .exe';
344+ if ( isValidPythonPath ( path . join ( pythonPath , executableName ) ) ) {
345+ return path . join ( pythonPath , executableName ) ;
346+ }
347+ if ( isValidPythonPath ( path . join ( pythonPath , 'scripts' , executableName ) ) ) {
348+ return path . join ( pythonPath , 'scripts' , executableName ) ;
349+ }
350350 }
351- if ( isValidPythonPath ( path . join ( pythonPath , 'bin' , 'python' ) ) ) {
352- return path . join ( pythonPath , 'bin' , 'python' ) ;
351+ else {
352+ if ( isValidPythonPath ( path . join ( pythonPath , executableName ) ) ) {
353+ return path . join ( pythonPath , executableName ) ;
354+ }
355+ if ( isValidPythonPath ( path . join ( pythonPath , 'bin' , executableName ) ) ) {
356+ return path . join ( pythonPath , 'bin' , executableName ) ;
357+ }
353358 }
354359 }
355360
0 commit comments