Fix Python – Pip freeze vs. pip list

Question

Asked By – nitrl

Why does pip list generate a more comprehensive list than pip freeze?

$ pip list
feedparser (5.1.3)
pip (1.4.1)
setuptools (1.1.5)
wsgiref (0.1.2)
$ pip freeze
feedparser==5.1.3
wsgiref==0.1.2

Pip’s documentation states:

   
freeze Output installed packages in requirements format.
list List installed packages.

What is a “requirements format”?

Now we will see solution for issue: Pip freeze vs. pip list


Answer

One may generate a requirements.txt via:

$ pip freeze > requirements.txt

A user can use this requirements.txt file to install all the dependencies. For instance:

$ pip install -r requirements.txt

The packages need to be in a specific format for pip to understand, such as:

# requirements.txt
feedparser==5.1.3
wsgiref==0.1.2
django==1.4.2
...

That is the “requirements format”.

Here, django==1.4.2 implies install django version 1.4.2 (even though the latest is 1.6.x).
If you do not specify ==1.4.2, the latest version available would be installed.

You can read more in “Virtualenv and pip Basics“,
and the official “Requirements File Format” documentation.

This question is answered By – karthikr

This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0