Motivation
I've been looking for several options to upgrade my local python packages installed via pip
. I've read some posts at stackoverflow and some github.com issues addressing different ways to upgrade them, but I was not very satisfied. I tried to make things on my own and here's how I did it.
Updating pip/pip3
packages
I knew that the command list
of pip/pip3
consoles return the list of locally installed python packages. Just needed to take that output, process it and use it to feed pip/pip3
itself in order to get the packages updated.#!/bin/bash | |
# Simplified forms using awk | |
pip install --upgrade $(pip list | awk '{printf(" %s ",$1)}') | |
pip3 install --upgrade $(pip3 list | awk '{printf(" %s ",$1)}') | |
# Alternative forms using sed | |
#pip install --upgrade $(pip list | awk -F" " '{print $1}' | sed ':a;N;s/\n/ /g;ba') # Alternative form | |
#pip3 install --upgrade $(pip3 list | awk -F" " '{print $1}' | sed ':a;N;s/\n/ /g;ba') # Alternative form |
I hope you find this useful!