I know how to see installed Python packages using pip, just use pip freeze
. But is there any way to see the date and time when package is installed or updated with pip?
I know how to see installed Python packages using pip, just use pip freeze
. But is there any way to see the date and time when package is installed or updated with 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
.