Można wymienić wszystkie lokalizacje, które przechowuje pakiety, a następnie po prostu listę wszystkich plików w tych katalogach (wraz z czasem tworzenia):
import pip
import os
import time
pkg_location_dir_strset = set()
for pip_pkg in pip.get_installed_distributions():
if pip_pkg.location not in pkg_location_dir_strset:
pkg_location_dir_strset.add(pip_pkg.location)
for pkg_location_dir_str in pkg_location_dir_strset:
print("")
print("Directory: " + pkg_location_dir_str)
for file_or_dir in os.listdir(pkg_location_dir_str):
# print("file_or_dir = " + file_or_dir)
file_or_dir_path = os.path.join(pkg_location_dir_str, file_or_dir)
print(
os.path.basename(file_or_dir).ljust(50)
+ " " + time.ctime(os.path.getctime(file_or_dir_path))
)
także check out this answer for an alternative solution który może wolisz
Nadzieja to pomaga!
Dlaczego to ma znaczenie, kiedy zostały zainstalowane? – jonrsharpe
@Ajay, myślę, że on oznacza tych, którzy użyli 'pip install' for. –
IronManMark20