See when packages were installed / updated using pip(查看何时使用 pip 安装/更新软件包)
问题描述
我知道如何使用 pip 查看已安装的 Python 包,只需使用 pip freeze
.但是有什么方法可以查看使用 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.
就像 Python 2 一样,带有 pip <10:
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)))
或类似的更新版本(使用 Python 3.7 测试并安装了带有 pkg_resources
的 setuptools 40.8):
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))))
在这两种情况下,输出都将类似于 numpy 1.12.1: Tue Feb 12 21:36:37 2019
.
an output will look like numpy 1.12.1: Tue Feb 12 21:36:37 2019
in both cases.
顺便说一句:您可以使用 pip list
而不是使用 pip freeze
,它能够提供更多信息,例如通过 pip list -o代码>.
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
.
这篇关于查看何时使用 pip 安装/更新软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:查看何时使用 pip 安装/更新软件包


基础教程推荐
- 使用PyInstaller后在Windows中打开可执行文件时出错 2022-01-01
- 线程时出现 msgbox 错误,GUI 块 2022-01-01
- 何时使用 os.name、sys.platform 或 platform.system? 2022-01-01
- Python kivy 入口点 inflateRest2 无法定位 libpng16-16.dll 2022-01-01
- 如何在海运重新绘制中自定义标题和y标签 2022-01-01
- Dask.array.套用_沿_轴:由于额外的元素([1]),使用dask.array的每一行作为另一个函数的输入失败 2022-01-01
- 如何让 python 脚本监听来自另一个脚本的输入 2022-01-01
- 筛选NumPy数组 2022-01-01
- 用于分类数据的跳跃记号标签 2022-01-01
- 在 Python 中,如果我在一个“with"中返回.块,文件还会关闭吗? 2022-01-01