Saturday, February 10, 2018

How to upgrade outdated Python packages

[root@cdh-vm logs]# pip list --outdated --format=legacy 
argcomplete (1.8.2) - Latest: 1.9.3 [wheel]
backports.ssl-match-hostname (3.4.0.2) - Latest: 3.5.0.1 [sdist]
beautifulsoup4 (4.5.3) - Latest: 4.6.0 [wheel]
chardet (2.3.0) - Latest: 3.0.4 [wheel]
configobj (4.7.2) - Latest: 5.0.6 [sdist]
decorator (3.4.0) - Latest: 4.2.1 [wheel]
docx2txt (0.6) - Latest: 0.7 [sdist]
EbookLib (0.15) - Latest: 0.16 [sdist]
perf (0.1) - Latest: 1.5.1 [wheel]
psycopg2 (2.5.1) - Latest: 2.7.4 [wheel]
pycurl (7.19.0) - Latest: 7.43.0.1 [sdist]
pygobject (3.22.0) - Latest: 3.27.2 [sdist]
python-pptx (0.6.5) - Latest: 0.6.7 [sdist]
pyudev (0.15) - Latest: 0.21.0 [sdist]
pyxattr (0.5.1) - Latest: 0.6.0 [sdist]
setuptools (0.9.8) - Latest: 38.5.1 [wheel]
six (1.10.0) - Latest: 1.11.0 [wheel]
SpeechRecognition (3.6.3) - Latest: 3.8.1 [wheel]
urlgrabber (3.10) - Latest: 3.10.2 [sdist]
xlrd (1.0.0) - Latest: 1.1.0 [wheel]

[root@cdh-vm logs]# pip list --outdated --format=columns 
Package                      Version Latest   Type 
---------------------------- ------- -------- -----
argcomplete                  1.8.2   1.9.3    wheel
backports.ssl-match-hostname 3.4.0.2 3.5.0.1  sdist
beautifulsoup4               4.5.3   4.6.0    wheel
chardet                      2.3.0   3.0.4    wheel
configobj                    4.7.2   5.0.6    sdist
decorator                    3.4.0   4.2.1    wheel
docx2txt                     0.6     0.7      sdist
EbookLib                     0.15    0.16     sdist
perf                         0.1     1.5.1    wheel
psycopg2                     2.5.1   2.7.4    wheel
pycurl                       7.19.0  7.43.0.1 sdist
pygobject                    3.22.0  3.27.2   sdist
python-pptx                  0.6.5   0.6.7    sdist
pyudev                       0.15    0.21.0   sdist
pyxattr                      0.5.1   0.6.0    sdist
setuptools                   0.9.8   38.5.1   wheel
six                          1.10.0  1.11.0   wheel
SpeechRecognition            3.6.3   3.8.1    wheel
urlgrabber                   3.10    3.10.2   sdist
xlrd                         1.0.0   1.1.0    wheel

# Upgrade manually one by one
[root@cdh-vm logs]# pip install pycurl -U

# Upgrade all at once (high chance rollback if some package fail
# to upgrade
[root@cdh-vm logs]# pip install $(pip list --outdated --format=columns |tail -n +3|cut -d" " -f1) --upgrade

# Upgrade one by one using loop
[root@cdh-vm logs]# for i in  $(pip list --outdated --format=columns |tail -n +3|cut -d" " -f1); do pip install $i --upgrade; done