diff --git a/python/src/com/jetbrains/python/run/AbstractPythonRunConfiguration.java b/python/src/com/jetbrains/python/run/AbstractPythonRunConfiguration.java index b9f1142533b2..e4eb48d6ade9 100644 --- a/python/src/com/jetbrains/python/run/AbstractPythonRunConfiguration.java +++ b/python/src/com/jetbrains/python/run/AbstractPythonRunConfiguration.java @@ -94,10 +94,12 @@ public abstract class AbstractPythonRunConfiguration extends ModuleBasedConfigur return sdkHome; } + @Nullable public String getInterpreterPath() { String sdkHome; if (myUseModuleSdk) { Sdk sdk = PythonSdkType.findPythonSdk(getModule()); + if (sdk == null) return null; sdkHome = sdk.getHomePath(); } else { diff --git a/python/src/com/jetbrains/python/run/PythonCommandLineState.java b/python/src/com/jetbrains/python/run/PythonCommandLineState.java index 65997678a159..8ba67703836e 100644 --- a/python/src/com/jetbrains/python/run/PythonCommandLineState.java +++ b/python/src/com/jetbrains/python/run/PythonCommandLineState.java @@ -84,7 +84,7 @@ public abstract class PythonCommandLineState extends CommandLineState { return processHandler; } - protected GeneralCommandLine generateCommandLine() { + protected GeneralCommandLine generateCommandLine() throws ExecutionException { GeneralCommandLine commandLine = new GeneralCommandLine(); setRunnerPath(commandLine); @@ -96,8 +96,12 @@ public abstract class PythonCommandLineState extends CommandLineState { return commandLine; } - protected void setRunnerPath(GeneralCommandLine commandLine) { - commandLine.setExePath(myConfig.getInterpreterPath()); + protected void setRunnerPath(GeneralCommandLine commandLine) throws ExecutionException { + String interpreterPath = myConfig.getInterpreterPath(); + if (interpreterPath == null) { + throw new ExecutionException("Cannot find Python interpreter for this run configuration"); + } + commandLine.setExePath(interpreterPath); } protected void buildCommandLineParameters(GeneralCommandLine commandLine) { diff --git a/python/src/com/jetbrains/python/testing/PythonTestCommandLineStateBase.java b/python/src/com/jetbrains/python/testing/PythonTestCommandLineStateBase.java index bfbb5a834082..6c1bf40dbdcb 100644 --- a/python/src/com/jetbrains/python/testing/PythonTestCommandLineStateBase.java +++ b/python/src/com/jetbrains/python/testing/PythonTestCommandLineStateBase.java @@ -47,7 +47,7 @@ public abstract class PythonTestCommandLineStateBase extends PythonCommandLineSt return consoleView; } - protected GeneralCommandLine generateCommandLine() { + protected GeneralCommandLine generateCommandLine() throws ExecutionException { GeneralCommandLine cmd = new GeneralCommandLine(); setRunnerPath(cmd);