Python Forum
How to see the date of installation of python modules.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to see the date of installation of python modules.
#1
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,
newbieAuggie2019

"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs
Reply
#2
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?
newbieAuggie2019 likes this post
Sig:
>>> import this

The UNIX philosophy: "Do one thing, and do it well."

"The danger of computers becoming like humans is not as great as the danger of humans becoming like computers." :~ Konrad Zuse

"Everything should be made as simple as possible, but not simpler." :~ Albert Einstein
Reply
#3
(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!
newbieAuggie2019

"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs
Reply
#4
(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.
Sig:
>>> import this

The UNIX philosophy: "Do one thing, and do it well."

"The danger of computers becoming like humans is not as great as the danger of humans becoming like computers." :~ Konrad Zuse

"Everything should be made as simple as possible, but not simpler." :~ Albert Einstein
Reply
#5
(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!
rob101 likes this post
newbieAuggie2019

"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Compare current date on calendar with date format file name Fioravanti 1 249 Mar-26-2024, 08:23 AM
Last Post: Pedroski55
  Python date format changes to date & time 1418 4 621 Jan-20-2024, 04:45 AM
Last Post: 1418
  Python installation for old MacOS Yonix 1 498 Sep-21-2023, 03:32 PM
Last Post: menator01
  Installation of packages to newest Python version from previous one Andrzej_Andrzej 3 846 Jul-15-2023, 11:32 AM
Last Post: snippsat
  Getting "SSL client not supported by this Python installation" error prabirsarkar 0 966 Mar-13-2023, 05:01 PM
Last Post: prabirsarkar
  python installation/running inside singularity container erdemath 2 1,808 Sep-21-2022, 08:13 AM
Last Post: erdemath
Question Python V3.11 Installation Help Danno 2 1,110 Aug-11-2022, 02:30 AM
Last Post: Danno
  Python modules for accessing the configuration of relevant paths Imago 1 1,385 May-07-2022, 07:28 PM
Last Post: Larz60+
  Date format and past date check function Turtle 5 4,280 Oct-22-2021, 09:45 PM
Last Post: deanhystad
  Python modules to extract data from a graph? bigmit37 5 22,450 Apr-09-2021, 02:15 PM
Last Post: TysonL

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020