Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
545 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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...