Python Forum

Full Version: How to see the date of installation of python modules.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi again!

As my knowledge is still very very limited, I learn mostly by imitating code and then later on, I expand it or manipulate it, till I get what I want.

Due to some trials and errors, I have added quite a few modules to python. I'd like to identify them by date of installation, and then to eliminate them to free space on my computer.

I tried some options that didn't work. Some others, I don't understand, as the commands are for Linux and they don't seem to work on Windows.

Finally, I found some code that seemingly works:

import pkg_resources, os, time

for package in pkg_resources.working_set:
    print("%s: %s" % (package, time.ctime(os.path.getctime(package.location))))
but actually I think it doesn't, because ALL modules are shown with the same date and time, as you can see on this excerpt:

[...]
PyYAML 6.0: Tue Feb  7 01:43:59 2023
PyQt5 5.15.7: Tue Feb  7 01:43:59 2023
PyQtWebEngine 5.15.4: Tue Feb  7 01:43:59 2023
isort 5.9.3: Tue Feb  7 01:43:59 2023
psutil 5.9.0: Tue Feb  7 01:43:59 2023
traitlets 5.7.1: Tue Feb  7 01:43:59 2023
[...]
I also find it strange that the list is not alphabetically ordered, neither it is by date, as all modules are shown with the exact same date and time.

Did I make some mistake with the code?

Thanks for your help,
As I've no clue about your computer OS, this may or may not help...

I'm using a Linux based OS and as such, there is a directory located: /home/rob/.local/lib/python3.6/site-packages in which all of the packages that I have installed are located. So, if I look in there I can see the package name and the time/date that said package was installed; maybe you have something akin to that, in your computer file system?
(Mar-31-2023, 10:30 AM)rob101 Wrote: [ -> ]I'm using a Linux based OS and as such, there is a directory located: /home/rob/.local/lib/python3.6/site-packages in which all of the packages that I have installed are located. So, if I look in there I can see the package name and the time/date that said package was installed

Thanks a lot!

Yes, in my Windows 10 I have instead ...\MyName\miniconda3\Lib\site-packages, where as you said, I can see the files and their installation dates. If I order the list by dates, it looks that there are several files associated to each package. Do you think I can safely eliminate the files that I believe are associated to the modules I don't want anymore?

Thanks a lot again!
(Mar-31-2023, 11:31 AM)newbieAuggie2019 Wrote: [ -> ]Thanks a lot!
Do you think I can safely eliminate the files that I believe are associated to the modules I don't want anymore?

You're very welcome.

Depends on your motivation. The disk space (for example) should not be a huge overhead, depending on how many packages you've installed. I've never removed anything by simply deleting the files/folders; rather I use pip uninstall package_name to remove anything that I feel I need to (pip3 in fact, on my system). That way there's less of a chance that I'll break something, maybe something that is dependent on another package.
(Mar-31-2023, 12:13 PM)rob101 Wrote: [ -> ][...] I use pip uninstall package_name to remove anything that I feel I need to [...]. That way there's less of a chance that I'll break something, maybe something that is dependent on another package.

Great advice!

Thanks again!