Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSONDecodeError when checking for upgrades #139

Open
staticf0x opened this issue Jul 24, 2022 · 3 comments
Open

JSONDecodeError when checking for upgrades #139

staticf0x opened this issue Jul 24, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@staticf0x
Copy link

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_
@staticf0x staticf0x added the bug Something isn't working label Jul 24, 2022
@bonkey
Copy link

bonkey commented Jul 25, 2022

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?

@staticf0x
Copy link
Author

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.

@staticf0x
Copy link
Author

The place to start would be here:

_, output, _ = _pip.call("list", user = user, outdated = outdated, \
I think

If I have some time this week I can investigate it a bit more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants