I am using pip freeze > requirements.txt
and noticed some unfamiliar libraries that were added to the requirements file. Does pip freeze
only capture the libraries and dependencies that are specific to that directory or from the entire system?
It dumps all the libraries installed in your project including dependencies and sub-dependencies in the requirements. txt file. It still misses out on the libraries that are not installed using pip. It doesn't remove a library automatically if it is not being used in a project.
Therefore, you should use pip list and pip freeze as follows: If you want to check a list of packages with various conditions, use pip list . If you want to create requirements. txt , use pip freeze .
As you have noticed, pip freeze
doesn't capture the libraries specific to a directory but indeed all the package installed in the current environment (most likely the packages installed on your system or, if you are in a virtual environment without global access, those from that virtual environment).
You can try pip freeze
from an other directory an see that you are having the same results.
If you want to obtain the list of dependency packages for a specific project you might be interested in the pipreqs
package which precisely do that.
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