| 68 | } |
| 69 | |
| 70 | async installPythonModule(pipCommand: string) { |
| 71 | console.log('Installing python module', pipCommand); |
| 72 | const pythonPath = this.SurferPythonPath; |
| 73 | console.log('Python path', pythonPath); |
| 74 | if (process.platform === 'win32') { |
| 75 | let commandArgs = pipCommand.split(' '); |
| 76 | console.log( |
| 77 | 'command being sent', |
| 78 | ['python.exe', '-m'].concat(commandArgs), |
| 79 | ); |
| 80 | const pipInstallProcess = spawn( |
| 81 | pythonPath, |
| 82 | ['python.exe', '-m'].concat(commandArgs), |
| 83 | { |
| 84 | shell: true, |
| 85 | }, |
| 86 | ); |
| 87 | |
| 88 | pipInstallProcess.stdout.on('data', (data) => { |
| 89 | console.log(`stdout: ${data}`); |
| 90 | }); |
| 91 | |
| 92 | pipInstallProcess.stderr.on('data', (data) => { |
| 93 | console.error(`stderr: ${data}`); |
| 94 | }); |
| 95 | } else { |
| 96 | const { stdout, stderr } = await execAsync( |
| 97 | `${pythonPath} -m ${pipCommand}`, |
| 98 | ); |
| 99 | console.log('stdout:', stdout); |
| 100 | console.log('stderr:', stderr); |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | async updatePipPython() { |
| 105 | console.log('Updating pip'); |