You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

如何检查Python包的最后更新时间?基于Conda包管理器的技术问询

Absolutely, there are several straightforward ways to check when your Python packages were last updated or installed in a Conda environment—perfect for tracking down unexpected changes that might be causing your program's odd behavior. Let's break them down:

1. Check individual package install/update times with Conda

Conda has a built-in flag to show install timestamps directly in the package list. Run this command in your activated environment:

conda list --show-install-times

This will output a table with an extra Installed time column, showing exactly when each package was added or updated. To narrow it down to a specific package (say, numpy), add the package name:

conda list --show-install-times numpy

2. Review Conda's environment revision history

Every time you modify your Conda environment (install, update, or remove packages), Conda saves a revision with a timestamp and the exact changes made. This is incredibly useful for spotting unexpected updates. Run:

conda list --revisions

The output will look something like this:

2024-05-20 14:32:11 (rev 12)

  • numpy 1.24.3 -> 1.26.0
  • pandas 2.0.1 -> 2.2.2

Each entry shows the timestamp, revision number, and all package changes from that session. You can immediately see if a package was updated at a time you didn't expect.

3. Use Pip for packages installed via Pip

If some of your packages were installed with Pip inside the Conda environment, you can check their install times with:

pip show <package-name>

Look for the Installed-Time field in the output, which gives the exact timestamp of installation/updates. For a broader view of all Pip-installed packages and their times, run:

pip list --verbose

This will display a table with an Installed Time column for every Pip-managed package.

4. Verify via environment directory file timestamps (fallback)

As a last resort, you can check the modification time of the package's folder in your Conda environment's site-packages directory. For an environment named myenv, the path might look like:

~/miniconda3/envs/myenv/lib/python3.11/site-packages/

Locate the folder for the package in question and check its last modified time. Note that this isn't as reliable as the Conda/Pip methods (folder changes could happen from other operations), but it can confirm timestamps you find elsewhere.

Start with the revision history—it's the quickest way to spot unexpected environment changes. Then use the package-specific commands to confirm details for the problematic package.

内容的提问来源于stack exchange,提问作者Amuoeba

火山引擎 最新活动