JSONDecodeError when checking for upgrades
staticf0x opened this issue · comments
Description
Running pipupgrade -c -l -u --pip-path ~/.local/bin/pip3
and I got this error:
"""
Traceback (most recent call last):
File "/usr/lib64/python3.10/concurrent/futures/process.py", line 246, in _process_worker
r = call_item.fn(*call_item.args, **call_item.kwargs)
File "/usr/lib64/python3.10/concurrent/futures/process.py", line 205, in _process_chunk
return [fn(*args) for args in chunk]
File "/usr/lib64/python3.10/concurrent/futures/process.py", line 205, in <listcomp>
return [fn(*args) for args in chunk]
File "/home/asdf/.local/lib/python3.10/site-packages/pipupgrade/commands/helper.py", line 322, in get_registry_from_pip
packages = json.loads(output)
File "/usr/lib64/python3.10/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/usr/lib64/python3.10/json/decoder.py", line 340, in decode
raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 3 column 1 (char 2354)
"""
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/asdf/.local/lib/python3.10/site-packages/pipupgrade/commands/__init__.py", line 79, in command
return _command(**ARGUMENTS)
File "/home/asdf/.local/lib/python3.10/site-packages/pipupgrade/commands/__init__.py", line 240, in _command
for registry in pool.imap_unordered(
File "/usr/lib64/python3.10/concurrent/futures/process.py", line 570, in _chain_from_iterable_of_lists
for element in iterable:
File "/usr/lib64/python3.10/concurrent/futures/_base.py", line 609, in result_iterator
yield fs.pop().result()
File "/usr/lib64/python3.10/concurrent/futures/_base.py", line 446, in result
return self.__get_result()
File "/usr/lib64/python3.10/concurrent/futures/_base.py", line 391, in __get_result
raise self._exception
json.decoder.JSONDecodeError: Extra data: line 3 column 1 (char 2354)```
Tried deleting the contents of `~/.config/pipupgrade` but that didn't do anything.
### Screenshot
_No response_
### Console errors
_No response_
I experienced the same. I found out that running:
/opt/homebrew/bin/pip list --outdated --format json
returned
[{"name": "pip", "version": "22.1.2", "latest_version": "22.2", "latest_filetype": "wheel"}]
[notice] A new release of pip available: 22.1.2 -> 22.2
[notice] To update, run: python3.9 -m pip install --upgrade pip
So, I did run python3.9 -m pip install --upgrade pip
and no more errors, but I guess only because /opt/homebrew/bin/pip list --outdated --format json
returns empty array ([]
).
Perhaps the issue is with extra notice text:
[notice] A new release of pip available: 22.1.2 -> 22.2
[notice] To update, run: python3.9 -m pip install --upgrade pip
Which is not parseable JSON but is presented on stdout?
Hah gotcha thanks @bonkey, upgrading pip solved it. It's exactly as you mentioned, pip 22.1.2 produces
[notice] A new release of pip available: 22.1.2 -> 22.2
[notice] To update, run: pip install --upgrade pip
so upgrading pip to the latest version (22.2) fixes that. You can get rid of the notice by adding --disable-pip-version-check
, then the JSON is parseable (tried in iPython). There is a related bug opened in the pip repository: pypa/pip#10881 but if my tests are correct, in pipupgrade it could be solved just by adding the --disable-pip-version-check
flag.
The place to start would be here:
pipupgrade/src/pipupgrade/commands/helper.py
Line 319 in 8260e49
If I have some time this week I can investigate it a bit more.