There have been numerous upgrades to python and TLJH recently. My IT guy wanted a script to make upgrading easier so I made one for him.
#! /bin/sh
sudo -E -H pip list --outdated --format=freeze | sed ‘s/==/>=/g’ | sudo -E -H xargs pip install --upgrade
pip check
We saved this as tljh-upgrade
The first part
sudo -E -H pip list --outdated --format=freeze
make a list of packages that must be upgraded in freeze format which shows the current version of each package
sed ‘s/==/>=/g’
Replaces all the == with >= so the packages will look for upgraded packages.
The last part
sudo -E -H xargs pip install --upgrade
does the actual upgrade. xargs takes the out put of the second part and appends it to the command line for the pip install --upgrade.
We have tested it and it works.
We out this in a bash script and did a chmod +x tljh-upgrade on the script file to it executable.
This script file can also be used just to upgrade python but the -E -H after the sudo isn’t necessary and it may be safer to add --user after the --upgrade.