Skip to content

pip list and pip freeze treat invalid packages differently #9235

Closed
@eamars

Description

@eamars

Environment

  • pip version: Up to 20.3.1
  • Python version: 3.7.7
  • OS: Windows 10 20H2

Description

Calling pip list will incorectly include invalid packages from site-packages folder. In contrast, pip freeze will report warnings and exclude them from the list.

Expected behavior

Package list reported by pip list and pip freeze should be consistent.

How to Reproduce

  1. Create a new virtual environment
  2. Install any package, rename the package_name.dist-info to ~package_name.dist-info
  3. Call pip list and pip freeze --all and observe the output.

Output
I renamed pandas-1.1.4.dist-info to ~pandas-1.1.4.dist-info as an example:

Output from pip list:

Package         Version
--------------- -------
-pandas         1.1.4
numpy           1.19.4
pip             20.3.1
python-dateutil 2.8.1
pytz            2020.4
setuptools      46.0.0
six             1.15.0
wheel           0.34.2

Output from pip freeze --all:

WARNING: Could not generate requirement for distribution -pandas 1.1.4 (c:\users\rbao\envs\temp3\lib\site-packages): Parse error at "'-pandas='": Expected W:(abcd...)
numpy==1.19.4
pip==20.3.1
python-dateutil==2.8.1
pytz==2020.4
setuptools==46.0.0
six==1.15.0
wheel==0.34.2

Notes the pandas is excluded from the pip freeze while included in pip list.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions