raimon49 / pip-licenses

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

`--format=json` broken with `prettytable` #119

Closed adwhitMSM closed 1 year ago

adwhitMSM commented 2 years ago

Hi,

I was using this tool sucessfully until I added prettytable to my project (for other uses), then it broke. It seems that previously it was using the Ptable 'fallback' but once prettytable was installed it preferentially used that, and errored.

pip-licenses V3.5.3
prettytable V2.5.0
poetry V1.1.8
Python V3.9

Traceback

➜ poetry run pip-licenses --format=json
Traceback (most recent call last):
  File "/Users/me/Library/Caches/pypoetry/virtualenvs/project-fJIZ19Z2-py3.9/bin/pip-licenses", line 8, in <module>
    sys.exit(main())
  File "/Users/me/Library/Caches/pypoetry/virtualenvs/project-fJIZ19Z2-py3.9/lib/python3.9/site-packages/piplicenses.py", line 893, in main
    output_string = create_output_string(args)
  File "/Users/me/Library/Caches/pypoetry/virtualenvs/project-fJIZ19Z2-py3.9/lib/python3.9/site-packages/piplicenses.py", line 558, in create_output_string
    return table.get_string(fields=output_fields, sortby=sortby)
  File "/Users/me/Library/Caches/pypoetry/virtualenvs/project-fJIZ19Z2-py3.9/lib/python3.9/site-packages/piplicenses.py", line 349, in get_string
    formatted_rows = self._format_rows(rows, options)
TypeError: _format_rows() takes 2 positional arguments but 3 were given
raimon49 commented 2 years ago

@adwhitMSM Thanks for the detailed bug report.

I have seen the same error in my environment. To resolve this, I need to follow up on the prettytable#138 changes, but I don't have the time to do that right now.

If you can pinning the version of prettytable to 2.2.1 or lower in your poetry environment, this problem can be avoided.

adwhitMSM commented 2 years ago

Thanks, pinning the version worked

raimon49 commented 1 year ago

This issue has been resolved in pip-licenses 4.x https://pypi.org/project/pip-licenses/4.0.0/