Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PIP command to determine if the latest version is installed?

Is there a pip command that will determine whether the latest version of a package is installed?

I am writing a shell script that needs to determine if the latest version is installed. If not, then my script needs to manually install the package. (It's PIL if anyone's curious and needs to be installed manually because the headers and libraries for libjpeg are in a non-standard location.)

This answer describes how to retrieve the version of the package currently installed, but I would also need the latest version available for download and some way to compare versions.

like image 457
Nathan Osman Avatar asked Jul 22 '13 19:07

Nathan Osman


2 Answers

A more useful command might be pip list -o which gives you a list of your out-dated libraries.

$ pip list -o
dj-database-url (0.3.0) - Latest: 0.4.0 [sdist]
...

You could do something like:

$ pip list -o | grep PIL

And see if it returns any output.

like image 163
groovecoder Avatar answered Nov 15 '22 04:11

groovecoder


'pip search' gives you that information. e.g.:

$ pip search SOAPpy
SOAPpy                    - SOAP Services for Python
  INSTALLED: 0.12.0
  LATEST:    0.12.5

versus:

$ pip search MarkupSafe
MarkupSafe                - Implements a XML/HTML/XHTML Markup safe string for Python
  INSTALLED: 0.19 (latest)
like image 43
giavac Avatar answered Nov 15 '22 03:11

giavac