Skip to content

Simple one-line powershell command that upgrades all pip modules.

License

Notifications You must be signed in to change notification settings

Zcehtro/Pip-upgrade-all-modules

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Pip-upgrade-all-modules

Simple one-line powershell command that upgrades all pip modules.

Why?

Most websites online use pip freeze and pipe it to upgrade all modules, but freeze doesn't include these modules (output of pip list --outdated):

Package    Version Latest Type
---------- ------- ------ -----
pip        21.3.1  22.0.4 wheel
setuptools 58.1.0  62.0.0 wheel
wheel      0.37.0  0.37.1 wheel

And possibly others.

Simple solution

Pipe the result of each line in pip list --outdated.

pip list --outdated | Select-Object -Skip 2 | ForEach-Object {$_.split(' ')[0]} | ForEach-Object {pip install --upgrade $_}

Same result with short-hand version:

pip list --outdated | select -Skip 2 | % {pip install --upgrade $_.split(' ')[0]}

Workflow explained

  1. Get the list of outdated pip modules. (Same list produced above)

    pip list --outdated
  2. List produces a header and line separator. We want to skip those 2 lines. So:

    Select-Object -Skip 2
  3. Parse the text in each line so that we extract only the names. Using space as a delimiter, we will get the first word in the first element of each array.

    ForEach-Object {$_.split(' ')[0]}
  4. Pipe the output of the previous step to the command to upgrade said module.

    ForEach-Object {pip install --upgrade $_}

About

Simple one-line powershell command that upgrades all pip modules.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published