Upgrade Python Packages Using Windows PowerShell

I have installed quite a few python packages on my windows machine. Any time I had to upgrade the installed packages, I had to do it one by one; until I figured out a way to upgrade all using good old PowerShell script.

pip list

The PowerShell snippet:

$packages = pip freeze

foreach ($p in $packages) {
    $package = $p.Split('==')[0]
    Write-Host 'Upgrading package ' $package
    pip install $package --upgrade

Make sure to run the PowerShell script under administrator privileges using Run as administrator option. Run the script from the PowerShell console to upgrade all your installed python packages:

pip upgrade

Leave a Reply