See when packages were installed / updated using pip
installation, package, pip, python
Solution
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 slightly newer versions (tested with Python 3.7 and 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))))
or like that with current (December 2023) versions (tested with Python 3.11, using `importlib.metadata` since that can replace the deprecated `pkg_resources`):
from importlib.metadata import distributions
import os, time
for dist in distributions():
print("%s %s: %s" % (dist.metadata["Name"], dist.version, time.ctime(os.path.getctime(dist._path))))
an output will look like `numpy 1.26.2: Sat Dec 30 16:23:13 2023` in all 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`.
Problem
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?