Skip to content

Commit 0b375f6

Browse files
committed
Update interpreter path in kernel.json file
1 parent 3135fd1 commit 0b375f6

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/client/datascience/jupyter/kernels/kernelService.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,16 @@ export class KernelService {
180180
}
181181
const specModel: ReadWrite<Kernel.ISpecModel> = JSON.parse(await this.fileSystem.readFile(kernel.specFile));
182182

183+
// Ensure we use a fully qualified path to the python interpreter in `argv`.
184+
if (['python', 'python2', 'python3'].includes(specModel.argv[0].toLowerCase())) {
185+
if (specModel.argv[0].toLowerCase() !== 'conda'){
186+
// If conda is the first word, its possible its a conda activation command.
187+
specModel.argv[0] = interpreter.path;
188+
} else {
189+
traceWarning(`Unknown value in model.argv[0], ${specModel.argv[0]}. Kernel might not work as expected.`);
190+
}
191+
}
192+
183193
// Get the activated environment variables (as a work around for `conda run` and similar).
184194
// This ensures the code runs within the context of an activated environment.
185195
specModel.env = await this.activationHelper.getActivatedEnvironmentVariables(undefined, interpreter, true)
@@ -197,6 +207,7 @@ export class KernelService {
197207
await this.fileSystem.writeFile(kernel.specFile, JSON.stringify(specModel, undefined, 2));
198208
kernel.metadata = specModel.metadata;
199209

210+
traceInfo(`Kernel successfully registered for ${interpreter.path} with the name=${name} and spec can be found here ${kernel.specFile}`);
200211
return kernel;
201212
}
202213
/**

0 commit comments

Comments
 (0)