From 08b678b522aadb020bbc5512413fbcf7fec143ab Mon Sep 17 00:00:00 2001 From: Cory Rivera Date: Thu, 25 Jul 2019 11:07:22 -0700 Subject: [PATCH] Reinstall pip during python install on Windows to update shebangs in exe files. (#6494) --- .../src/jupyter/jupyterServerInstallation.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/extensions/notebook/src/jupyter/jupyterServerInstallation.ts b/extensions/notebook/src/jupyter/jupyterServerInstallation.ts index 363a6658f3..39852a40aa 100644 --- a/extensions/notebook/src/jupyter/jupyterServerInstallation.ts +++ b/extensions/notebook/src/jupyter/jupyterServerInstallation.ts @@ -425,17 +425,19 @@ export class JupyterServerInstallation { } private async installOfflinePipDependencies(): Promise { - let installJupyterCommand: string; - if (process.platform === constants.winPlatform) { - let cmdOptions = this._usingExistingPython ? '--user' : ''; - let requirements = path.join(this._pythonPackageDir, 'requirements.txt'); - installJupyterCommand = `"${this._pythonExecutable}" -m pip install ${cmdOptions} --no-index -r "${requirements}" --find-links "${this._pythonPackageDir}" --no-warn-script-location`; - } - - if (installJupyterCommand) { + // Skip this step if using existing python, since this is for our provided package + if (!this._usingExistingPython && process.platform === constants.winPlatform) { this.outputChannel.show(true); this.outputChannel.appendLine(localize('msgInstallStart', "Installing required packages to run Notebooks...")); + + let requirements = path.join(this._pythonPackageDir, 'requirements.txt'); + let installJupyterCommand = `"${this._pythonExecutable}" -m pip install --no-index -r "${requirements}" --find-links "${this._pythonPackageDir}" --no-warn-script-location`; await this.executeStreamedCommand(installJupyterCommand); + + // Force reinstall pip to update shebangs in pip*.exe files + installJupyterCommand = `"${this._pythonExecutable}" -m pip install --force-reinstall --no-index pip --find-links "${this._pythonPackageDir}" --no-warn-script-location`; + await this.executeStreamedCommand(installJupyterCommand); + this.outputChannel.appendLine(localize('msgJupyterInstallDone', "... Jupyter installation complete.")); } else { return Promise.resolve();