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?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
You could use the
--log
option:E.g:
Or you can set it in your
pip.conf
to be enabled by default:Then all the
pip
operations will be logged verbosely into the specified file along with a log separator and timestamp, e.g.:logs the following to ~/.pip/pip.append.log:
You could parse out what you need from this log. While not the nicest it's a standard
pip
facility.I don't know all
pip
options but for one module you can get list of its filesand then you can check its dates using python or bash.
For example list of files in
requests
moduleresult:
BTW: you can use
--help
to see more options for some functionsSolution 1 : packages.date.py :
Solution 2 : packages.alt.date.py :
Solution 1 & 2 compatibility :
pip freeze
gives you all the installed packages. Assuming you know the folder:time.ctime(os.path.getctime(file))
should give you the creation time of a file, i.e. date of when the package has been installed or updated.
I was recently looking for this too. But although there are many good answers here, the real issue is that since pip is not keeping logs by default, we have to resort to using the file creation and modification times, known as
ctime
andmtime
, respectively. (See MAC-times.) Unfortunately, using this method has two side effects:However, there is a tool called pip-date that try to combine a few different methods.
pip install pip-date
If its not necessary to differ between updated and installed, you can use the change time of the package file. Like that:
Btw: Instead of using
pip freeze
you can usepip list
which is able to provide some more information, like outdated packages viapip list -o
.