Notebooks: Fix pip installation not working (#14506)

* upgrade pip after python installation

* add comment

* only upgrade pip for new python installations

* reinstall pip version instead of upgrade to latest

* update comment

* get pip version through packages list
This commit is contained in:
Lucy Zhang
2021-03-03 17:44:45 -08:00
committed by GitHub
parent 2620d060dc
commit 74629c951d

View File

@@ -165,6 +165,13 @@ export class JupyterServerInstallation implements IJupyterServerInstallation {
let pythonExists = await utils.exists(this._pythonExecutable);
if (!pythonExists || forceInstall) {
await this.installPythonPackage(backgroundOperation, this._usingExistingPython, this._pythonInstallationPath, this.outputChannel);
// reinstall pip to make sure !pip command works
if (!this._usingExistingPython) {
let packages: PythonPkgDetails[] = await this.getInstalledPipPackages();
let pip: PythonPkgDetails = packages.find(x => x.name === 'pip');
let cmd = `"${this._pythonExecutable}" -m pip install --force-reinstall pip=="${pip.version}"`;
await this.executeBufferedCommand(cmd);
}
}
await this.upgradePythonPackages(forceInstall, packages);
} catch (err) {