From 74629c951d7e96d2358e315bf12a8f4b6652517f Mon Sep 17 00:00:00 2001 From: Lucy Zhang Date: Wed, 3 Mar 2021 17:44:45 -0800 Subject: [PATCH] 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 --- .../notebook/src/jupyter/jupyterServerInstallation.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/extensions/notebook/src/jupyter/jupyterServerInstallation.ts b/extensions/notebook/src/jupyter/jupyterServerInstallation.ts index 5394f79f17..85a867645a 100644 --- a/extensions/notebook/src/jupyter/jupyterServerInstallation.ts +++ b/extensions/notebook/src/jupyter/jupyterServerInstallation.ts @@ -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) {