Installing python3-pip to WSL Ubuntu 18.04 from Powershell

1

Scenario

In an automated installation procedure I am trying to install python3-pip. However during the manual installation of the package installer pip, I got a purple screen prompting me for a restart (of services). I was able to manually select "yes". However during the automated process I run from powershell, it appears to be "hanging" at the commands:

[String] $pip = "yes | sudo apt install python3-pip"
Write-Host ("7.2.c pip="+$pip)
$output = bash -c $pip

The manual install took 2-3 minutes max, I terminated the automated installation after 12 minutes (same device) new WSL installation. I am aware the yes | pipes a yes to a conventional y/n prompted and I hoped it would propagate to the purple screen y/n prompt as well, but it appears it does not.

Question

How can I automatically install python3-pip on WSL Ubuntu 18.04 using a powershel .ps1 script?

a.t.

Posted 2020-02-10T15:32:27.783

Reputation: 269

Answers

1

The following code sufficed to effectively install pip for python 3 on WSL ubuntu 18.04:

[String] $update = "yes | sudo apt-get update"
        Write-Host ("7.2.c update="+$update)
        #$output = bash -c $update

        [String] $update = "yes | sudo apt-get install python3-distutils"
        Write-Host ("7.2.c update="+$update)
        $output = bash -c $update

        [String] $pip = "curl -o get-pip.py https://bootstrap.pypa.io/get-pip.py"
        Write-Host ("7.2.c pip="+$pip)
        $output = bash -c $pip


        [String] $pip = "yes | sudo python3 get-pip.py"
        Write-Host ("7.2.c pip="+$pip)
        $output = bash -c $pip

It does not require the user to answer a y/n prompt on a purple screen.

a.t.

Posted 2020-02-10T15:32:27.783

Reputation: 269