See when packages were installed / updated using pip

If it’s not necessary to differ between updated and installed, you can use the change time of the package file.

Like that for Python 2 with pip < 10:

import pip, os, time

for package in pip.get_installed_distributions():
     print "%s: %s" % (package, time.ctime(os.path.getctime(package.location)))

or like that for newer versions (tested with Python 3.7 and installed setuptools 40.8 which bring pkg_resources):

import pkg_resources, os, time

for package in pkg_resources.working_set:
    print("%s: %s" % (package, time.ctime(os.path.getctime(package.location))))

an output will look like numpy 1.12.1: Tue Feb 12 21:36:37 2019 in both cases.

Btw: Instead of using pip freeze you can use pip list which is able to provide some more information, like outdated packages via pip list -o.

Leave a Comment