JSONDecodeError exception is raised
See original GitHub issueBug description
Upon following the README.md to install, successfully running given the examples within python projects. When I run outside of a python project; I get an error on a windows system. It’s needlessly verbose.
This isn’t just about me testing the fences or being obtuse. Sometimes CI and build servers (particularly in mono-repos) need to switch environments and working directories. This would absolutely impact the case for a windows runner in the wrong folder.
Reproduction steps
python3 -m pip install -U pip-audit
pip-audit
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots and logs
$ pip-audit
WARNING: You are using pip version 20.3.1; however, version 21.3.1 is available.
You should consider upgrading via the 'c:\python38amd64\python.exe -m pip install --upgrade pip' command.
←[?25hTraceback (most recent call last):
File "c:\python38amd64\lib\site-packages\pip_audit\_dependency_source\pip.py", line 64, in collect
for (_, dist) in pip_api.installed_distributions(local=self._local).items():
File "c:\python38amd64\lib\site-packages\pip_api\_installed_distributions.py", line 83, in installed_distributions
return _new_installed_distributions(local)
File "c:\python38amd64\lib\site-packages\pip_api\_installed_distributions.py", line 71, in _new_installed_distributions
for raw_dist in json.loads(result):
File "c:\python38amd64\lib\json\__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "c:\python38amd64\lib\json\decoder.py", line 340, in decode
raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 30318)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "c:\python38amd64\lib\runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\python38amd64\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Python38amd64\Scripts\pip-audit.exe\__main__.py", line 7, in <module>
File "c:\python38amd64\lib\site-packages\pip_audit\_cli.py", line 240, in audit
for (spec, vulns) in auditor.audit(source):
File "c:\python38amd64\lib\site-packages\pip_audit\_audit.py", line 60, in audit
yield from self._service.query_all(specs)
File "c:\python38amd64\lib\site-packages\pip_audit\_service\interface.py", line 115, in query_all
for spec in specs:
File "c:\python38amd64\lib\site-packages\pip_audit\_dependency_source\pip.py", line 81, in collect
raise PipSourceError("failed to list installed distributions") from e
pip_audit._dependency_source.pip.PipSourceError: failed to list installed distributions
Platform information
- OS name and version: Windows 10 64-bit Pro
pip-audit
version (pip-audit -V
): 1.0.0- Python version (
python -V
orpython3 -V
): 3.8.1 😬 (I’ll upgrade that separately) pip
version (pip -V
orpip3 -V
): 21.1.2
Additional context
I Understand I should perhaps use flags.
I expected this to be the default, or for usage to be output if I supply no default command.
-
pip-audit -l
works -
pip-audit --help
works -
pip-audit -r /path/to/requirements.txt
works for both existing and non-existing paths
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
python - Handle JSON Decode Error when nothing returned
It means that you should catch exceptions instead of checking values for validity. Thus, try the following: try: qByUser = byUsrUrlObj.read() ...
Read more >Python JSONDecodeError Explanation and Solution | CK
The Python JSONDecodeError indicates there is an issue with how a JSON object is formatted. To fix this error, you should read the...
Read more >json — JSON encoder and decoder — Python 3.11.1 ...
This can be used to raise an exception if invalid JSON numbers are encountered. ... is not a valid JSON document, a JSONDecodeError...
Read more >JSONDecodeError exception is raised · Issue #155 - GitHub
When I run outside of a python project; I get an error on a windows system. It's needlessly verbose. This isn't just about...
Read more >Python json.JSONDecodeError() Examples - ProgramCreek.com
JSONDecodeError : raise InvalidAPIParameters(extra_msg='No request body! ... Addition of {} is the cause'.format(', '.join(new)) raise DeisException(message).
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
TBF, I will just avoid using this on windows. That is my fix for myself 😄
Hmm, that
JSONDecoderError
is fishy — looks similar to #116, which we never fully root caused.Sent from mobile. Please excuse my brevity.