Bạn có thể liệt kê tất cả các địa điểm chứa các gói và sau đó chỉ cần liệt kê tất cả các tập tin trong các thư mục này (cùng với thời gian sáng tạo):
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))
)
Cũng check out this answer for an alternative solution mà bạn có thể thích
Hope điều này có ích!
Tại sao lại quan trọng khi cài đặt? – jonrsharpe
@Ajay, tôi nghĩ rằng anh ấy có nghĩa là những người mà anh ấy đã sử dụng 'pip install' cho. –
IronManMark20