pip list --format json output ends with \x1b[0m -> JSONdecode error
See original GitHub issueDescription
Using version 22.0.3 the output of pip list ends with \x1b[0m. (version 21.3.1 does not have this issue) For pip list this is not the problem, but pip list --format json has the same behaiour. -> json.decoder.JSONDecodeError: Extra data
The following options do not change the behaviour.
- –disable-pip-version-check
- –no-python-version-warning
- –no-color
Expected behavior
pip list --format json should end with a line seperator.
pip version
22.0.3
Python version
3.9.7
OS
Win10
How to Reproduce
import json
import subprocess
json.loads(subprocess.check_output(("pip", "list", "--format", "json"))
Output
json.decoder.JSONDecodeError: Extra data
Code of Conduct
- I agree to follow the PSF Code of Conduct.
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
python - Handle JSON Decode Error when nothing returned
Unfortunately, json. loads throws a TypeError when the JSON object isn't a str, bytes, or bytearray. This bit me recently because I had...
Read more >Python JSON tricks: how to deal with JSONDecodeError
Trick 1: You should use double quotes for keys and values, otherwise you will have the JSONDecodeError error:
Read more >pipdeptree - PyPI
pipdeptree is a command line utility for displaying the installed python packages in form of a dependency tree. It works for packages installed...
Read more >pip list - pip documentation v22.3.1
Select the output format among: columns (default), freeze, or json. --not-required#. List packages that are not dependencies of installed packages.
Read more >Check all installed Python packages with pip list/freeze
If the output format is columns or json , the currently installed version and the latest version are output together. $ pip list...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@pradyunsg Can’t think of any reason it would, but I wouldn’t rule it out 100%. I’ll see if I can replicate this.
This is also causing problems with pip-audit, any attempt to actually parse the json causes errors.
I am happy to help diagnose the issue. At the moment my workaround is to stick with pip 21.3.1 which does not have this issue.
I can confirm that subprocess is called with stdout = PIPE, I can also provide environment information etc if required.
Also from what I can tell the options passed to rich are correct, style ends up set to None as I would expect.
Win 11