raimon49 / pip-licenses

Dump the license list of packages installed with pip.
MIT License
307 stars 43 forks source link

Update to pip-21.3 breaks pip-licenses #113

Closed stishkin closed 2 years ago

stishkin commented 2 years ago

/mnt/user$ pip-licenses -uf json

Traceback (most recent call last):
  File "/home/user/.local/lib/python3.8/site-packages/piplicenses.py", line 42, in <module>
    from pip._internal.utils.misc import get_installed_distributions
ImportError: cannot import name 'get_installed_distributions' from 'pip._internal.utils.misc' (/home/user/.local/lib/python3.8/site-packages/pip/_internal/utils/misc.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/.local/bin/pip-licenses", line 5, in <module>
    from piplicenses import main
  File "/home/user/.local/lib/python3.8/site-packages/piplicenses.py", line 44, in <module>
    from pip import get_installed_distributions
ImportError: cannot import name 'get_installed_distributions' from 'pip' (/home/user/.local/lib/python3.8/site-packages/pip/__init__.py)
s4ke commented 2 years ago

workaround for now should be manually pinning pip

pip install --upgrade pip==21.2.4

SlavaSkvortsov commented 2 years ago

If someone still wants to have the latest pip version you can use a fork while my PR is still on the review - git+git://github.com/adjust/pip-licenses.git@v-3.5.3

raimon49 commented 2 years ago

I have shipped pip-licenses 3.5.3 with this issue resolved. https://pypi.org/project/pip-licenses/3.5.3/

@stishkin @s4ke @SlavaSkvortsov Thanks for the useful report and patch!

s4ke commented 2 years ago

Glad to be of help :). This package helps us a lot, so providing a workaround is the least I can do :)