I've been working on a project for a while now and have installed various packages over the time I've worked with it, some of which I suspect are no longer required to run the code, and I don't want to include them in the requirements.txt
. Is there any way to know which installed packages in my venv are either imported somewhere in my Python project or are a dependency of a package that is imported, so that I can remove the unused packages from the requirements.txt
?
- My question is related to How can I 'clean up' a virtualenv? but is not the same, because in that case the OP knew which top-level package (of several he installed) he wanted to keep, and was trying to figure out how to uninstall the others along with their dependencies, while in my case I don't even know which top-level packages I need.
- My question is similar to this one regarding the R programming language.