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
?
I found a solution to my problem here: use pipreqs to get a list of the top-level packages actually required by a project:
pip install pipreqs
and then pipreqs .
(from the top level of your project).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With