0

I want to troubleshoot my environment which may have been affected by recently installed packages.

Elj
  • 557
  • 3
  • 13
  • 1
    I'm fairly certain that neither of those tools keeps track of _when_ something was installed. – ChrisGPT was on strike Dec 01 '21 at 12:16
  • 1
    Neither of these do it by default, but you can use this answer to see when each package was last updated/installed. This answer also nicely sorts the results. https://stackoverflow.com/a/44436961/13801789 – yuuuu Dec 01 '21 at 12:18
  • If I'm understood correct, you need a list of packages installed by pip. Please check with a command "history | grep pip " – iamniki Dec 01 '21 at 12:19
  • 1
    Side note: I suspect that whatever problem you're facing would be less likely to occur with single-purpose virtual environments to isolate one set of dependencies from another. – ChrisGPT was on strike Dec 01 '21 at 12:20
  • Does this answer your question? [See when packages were installed / updated using pip](https://stackoverflow.com/questions/24736316/see-when-packages-were-installed-updated-using-pip) – yuuuu Dec 01 '21 at 12:21
  • Hi everyone, I have solved the issue. Thanks. There was an answer below recommending 'conda update --all'. I have used it before, so I put that into the terminal. Upon looking at the list under 'The following packages will be REMOVED:', I spotted a package that might have caused it. I uninstalled that package, and my environment is okay now. I am unfamiliar with what I should do now - do I delete my question or rephrase it? – Elj Dec 01 '21 at 12:34
  • Thank you @yuuuu, although I will only test that if I need it in future again. – Elj Dec 01 '21 at 12:35
  • Thanks @NikhilGowdaShivaswmay, but I got "'history' is not recognized as an internal or external command, operable program or batch file.' – Elj Dec 01 '21 at 12:36
  • An answer below suggested https://github.com/E3V3A/pip-date/, so that might be an option for anyone interested (although it's just for pip-based installations). – Elj Dec 01 '21 at 12:49
  • 2
    For `conda`, have you tried `conda list -r`? – FlyingTeller Dec 01 '21 at 13:45
  • Hi @FlyingTeller, just discovered it. Thanks! – Elj Dec 01 '21 at 13:52
  • 1
    Mostly covered in [this answer](https://stackoverflow.com/a/56069934/570918), but not the pip part. And yes, Conda does track exactly when packages were installed. – merv Dec 01 '21 at 17:38

1 Answers1

0

You can do something like this:

import os
import time
from pip._internal.utils.misc import get_installed_distributions

for package in get_installed_distributions():
    print ("{}\t{}".format(time.ctime(os.path.getctime(package.location)), package))

Or you can use pip-date.

Stoobish
  • 1,202
  • 4
  • 23
  • Hi @Stoobish, I did not test this in my terminal, but it seems like old code that has since been deprecated: https://stackoverflow.com/questions/49923671/are-there-any-function-replacement-for-pip-get-installed-distributions-in-pip. The pip-date option is interesting and could be a potential solution! – Elj Dec 01 '21 at 12:46