Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using pip freeze > requirements.txt will copy the libraries specific to that directory?

Tags:

python

pip

pypi

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?

like image 310
Wunderbread Avatar asked Jul 24 '17 18:07

Wunderbread


People also ask

What does pip freeze requirements txt do?

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.

What is the difference between pip freeze and pip list?

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 .


1 Answers

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.

like image 193
mgc Avatar answered Oct 19 '22 05:10

mgc