Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
542 views
in Technique[技术] by (71.8m points)

python - Get date and time of installation for packages installed via pip

I would like to find a way to get the calendar date and time in hour:minute:seconds format for my packages installed via pip.

I would like to be able to see something in output like: Month/Day/Year - Hour:Minute:Seconds for each package.

Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Is this what you are looking for -

import pip
import os
import time

In [139]: for package in pip.get_installed_distributions():
   .....:          print "%s: %s" % (package, time.ctime(os.path.getctime(package.location)))
   .....:     
pyudev 0.17.dev20150317: Tue Mar 17 12:02:58 2015
python-magic 0.4.6: Fri Mar 20 14:07:59 2015
runipy 0.1.0: Fri Oct 31 01:49:34 2014

Source of the code - https://stackoverflow.com/a/24736563/170005

You can do import pip too, which is pretty interesting. I didn't know this.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...