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 on Python 3.10 #4210

Closed
3 tasks done
robd003 opened this issue Jun 24, 2021 · 40 comments
Closed
3 tasks done

JSONDecodeError on Python 3.10 #4210

robd003 opened this issue Jun 24, 2021 · 40 comments
Labels
kind/bug Something isn't working as expected

Comments

@robd003
Copy link

robd003 commented Jun 24, 2021

Issue

Poetry crashes whenever it evaluates a package for installation. Running poetry install will return JSONDecodeError 100% of the time.

$ poetry install
Installing dependencies from lock file

Package operations: 16 installs, 0 updates, 0 removals

  • Installing sanic-routing (0.6.2): Failed

  JSONDecodeError

  Expecting value: line 1 column 1 (char 0)

  at /usr/local/Cellar/python@3.10/3.10.0b3/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/decoder.py:355 in raw_decode
      351│         """
      352│         try:
      353│             obj, end = self.scan_once(s, idx)
      354│         except StopIteration as err:
    → 355│             raise JSONDecodeError("Expecting value", s, err.value) from None
      356│         return obj, end
      357│ 
@robd003 robd003 added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Jun 24, 2021
@robd003
Copy link
Author

robd003 commented Jun 25, 2021

I've tried removing the entire pypoetry cache directory and still having the same issue

@robd003
Copy link
Author

robd003 commented Jun 25, 2021

Just tried the 1.2.0a1 release and it's working fine.

@robd003
Copy link
Author

robd003 commented Jun 25, 2021

The 1.1.7 update pushed out today still has the same problem on Python 3.10

@hoefling
Copy link
Contributor

hoefling commented Jul 5, 2021

Reproducible with 3.10 on Linux & Windows as well.

br3ndonland added a commit to br3ndonland/fastenv that referenced this issue Jul 6, 2021
python-poetry/poetry#3706
python-poetry/poetry#3870
python-poetry/poetry#4056

Poetry has a new install script, added in python-poetry/poetry#3706.
The old get-poetry.py install script is not compatible with Python 3.10.
This commit will update the GitHub Actions workflow to use the new
install-poetry.py script, with `POETRY_HOME=/opt/poetry` for consistent
installs independent of user account, and will also update the workflow
to use a virtualenv and run commands with `poetry run` to avoid issues
with `POETRY_VIRTUALENVS_CREATE=false`.

As of Poetry 1.1.7, there may be complications with install-poetry.py
run without venvs (`POETRY_VIRTUALENVS_CREATE=false`). An error is seen:

```text
OSError

Could not find a suitable TLS CA certificate bundle, invalid path:
/opt/poetry/venv/lib/python3.9/site-packages/certifi/cacert.pem

at /opt/poetry/venv/lib/python3.9/site-packages/requests/adapters.py:227
in cert_verify
```

Poetry may be incorrectly attempting to read from its virtualenv if it's
not respecting `POETRY_VIRTUALENVS_CREATE` (python-poetry/poetry#3870).
Downstream steps also do not respect `POETRY_VIRTUALENVS_CREATE`, so the
application does not run. To avoid these issues, `poetry run` can be
prepended to commands to prompt Poetry to use its virtualenv.

Additionally, Poetry errors out with a `JSONDecodeError` when attempting
to install packages with Python 3.10 (python-poetry/poetry#4210). Python
3.10 support will be postponed until Poetry is compatible.
@hoefling
Copy link
Contributor

BTW disabling poetry's experimental new installer may be a workaround for now:

$ poetry config experimental.new-installer false

@seandstewart
Copy link

I can confirm that the issue is resolved by @hoefling's suggestion.

BTW disabling poetry's experimental new installer may be a workaround for now:

$ poetry config experimental.new-installer false

@dmerejkowsky
Copy link
Contributor

dmerejkowsky commented Aug 20, 2021

I can confirm I can reproduce with version 1.1.8 here. Poke @python-poetry/triage

@dmerejkowsky
Copy link
Contributor

And this is fixed in 1.2.0a2. I guess we can close this ?

@remram44
Copy link
Contributor

I am glad I found this issue. I wouldn't have known how to even debug this, since Poetry eats the whole traceback I only shows this JSONDecodeError.

Is there a way to print the traceback?

@BSVogler
Copy link

Anyone got this on 3.9.7? I get

 • Installing pycparser (2.20): Failed

  JSONDecodeError

  Expecting value: line 1 column 1 (char 0)

  at /usr/local/Cellar/python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/decoder.py:355 in raw_decode

@ksamuel
Copy link

ksamuel commented Oct 2, 2021

Same here, with a project with both 3.9 and 3.10 env. Removing the 3.10 env solve the problem. However, 3.10 will be released in 2 days, so I don't think we should be surprise there are still things that don't work yet.

@jodal
Copy link
Contributor

jodal commented Oct 3, 2021

Reproduced with Poetry 1.1.10 installed on Python 3.9.5 (Ubuntu 21.04 system Python) using pipx.

poetry install started failing immediately when I switched project from Python 3.9.7 to 3.10.0rc2, which is due for final release tomorrow.

Works:

pyenv local 3.9.7
poetry env use $(pyenv which python)
poetry install

Fails:

pyenv local 3.10.0rc2
poetry env use $(pyenv which python)
poetry install

Poetry eats most of the stack trace. I see the following repeated once for each dependency:

Installing urllib3 (1.26.7): Failed

  JSONDecodeError

  Expecting value: line 1 column 1 (char 0)

  at /usr/lib/python3.9/json/decoder.py:355 in raw_decode
      351│         """
      352│         try:
      353│             obj, end = self.scan_once(s, idx)
      354│         except StopIteration as err:
    → 355│             raise JSONDecodeError("Expecting value", s, err.value) from None
      356return obj, end
      357

Removing the Poetry cache with rm -r ~/.cache/pypoetry/cache/ or m -r ~/.cache/pypoetry/ does not improve the situation.

Disabling the experimental installer with poetry config experimental.new-installer false does resolve the issue, so that at least serves as an indication of what part of Poetry is failing.

@laoshaw
Copy link

laoshaw commented Oct 4, 2021

same issue with python 3.10-rc2 while 3.10 is supposed to be released today. python 3.9 worked well.

with 3.10-rc2, poetry config experimental.new-installer false can make this error disappear.

@playpauseandstop
Copy link
Contributor

playpauseandstop commented Oct 4, 2021

Hi all,

Wanted to update you that given error should gone with latest poetry==1.1.11 release.

With given release you don’t need to disable experimental new installer to install your dependencies with poetry at 3.10.0rc2 or 3.10.0.

@ksamuel
Copy link

ksamuel commented Oct 5, 2021

Confirmed for me, fresh stable 3.10 works with latest poetry.

Be careful when upgrading, there are packages that don't have a wheel yet, and you'll need to compile them while in 3.9, you didn't need to.

For me, you can close the ticket.

@emersonmx
Copy link

I use rm -rf ~/.cache/pypoetry/cache/.

@finswimmer
Copy link
Member

Hello everyone,

as others already mention this issue is solved by a new version of cachecontrol.

If you install poetry by the install-poetry.py scrip, the new version is installed automatically.

If you use the deprecated get-poetry.py script, it is not possible to update the cachecontrol version. get-poetry.py vendores the dependencies based on poetry's lock file. get-poetry.py installs poetry 1.1 which still supports python2. The current version of cachecontrol doesn't support python2 anymore, thus we cannot update the locked version in the 1.1 branch.

TL;DR;: Install poetry with the install-poetry.py to resolve this issue.

fin swimmer

@jcowles
Copy link

jcowles commented Mar 18, 2022

fresh install with install-poetry.py, deleting poetry.lock, and latest version of cachecontrol did not fix the issue for me, FYI

@jcowles
Copy link

jcowles commented Mar 18, 2022

The problem for me is that something was spewing "Cannot find the file specified" when launching python. Poetry initializes by running python and printing "sys.path" and then attempts to decode this using the json parser.

The JSON parser fails (loads) because the json string starts with "Cannot find the file specified", and of course that's not valid json.

Still a total mystery what is spewing that string though

hoefling added a commit to hoefling/devpi-client-extensions that referenced this issue Apr 15, 2022
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
@edmondop
Copy link

Installed poetry using pip on Windows on 3.9.6, cannot get poetry install to work :( Tried all suggesitons in this post, with no luck

@clintonroy
Copy link
Contributor

Installed poetry using pip on Windows on 3.9.6, cannot get poetry install to work :( Tried all suggesitons in this post, with no luck

This bug is closed. If you have a new bug, please create a new bug report, with all the details requested (inputs, outputs, errors, exactly what commands you ran).

@sandys
Copy link

sandys commented Jul 4, 2022

is this bug fixed ? im running a fresh conda install on Windows WSL Ubuntu with Conda and Python 3.10 just now. I had the exact same issue. Only thing that worked was poetry config experimental.new-installer false

@jamesowers-roo
Copy link

jamesowers-roo commented Jul 8, 2022

If anyone else gets here: my issue was not solved by changing config, nor by a complete reinstall of poetry.

Solution: Simply delete and recreate my currently activated virtual environment.

Explanation: as @jcowles suggests above, my currently activated virtual environment python was semi-borked. It was, unbeknownst to me, dishing out a nice error message (but still actually functioning fine somehow):

% python
Error processing line 1 of /Users/james/miniconda/envs/mamod/lib/python3.7/site-packages/distutils-precedence.pth:

  Traceback (most recent call last):
    File "/Users/james/miniconda/envs/mamod/lib/python3.7/site.py", line 168, in addpackage
      exec(line)
    File "<string>", line 1, in <module>
  ModuleNotFoundError: No module named '_distutils_hack'

Remainder of file ignored
Python 3.7.13 (default, Mar 28 2022, 07:24:34)
[Clang 12.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

This looks to be related to pypa/setuptools#2957. Presumably I had broken my venv via various installations.

So my advice if you get a JSONDecodeError with poetry is to simply execute python, and see if you get a weird error and, if so, just trash and recreate your venv.

@clintonroy - we could raise a feature request for poetry to handle the JSON parsing more gracefully? I believe this is done within this file: https://github.com/python-poetry/poetry/blob/ae03bdcdecbb00f2691dbd0f78c08fc010e87779/src/poetry/utils/env.py

hoefling added a commit to hoefling/devpi-client-extensions that referenced this issue Aug 22, 2022
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
hoefling added a commit to hoefling/devpi-client-extensions that referenced this issue Aug 22, 2022
* don't run the ci twice per each pull request

Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>

* try out running ci with pypy 3.9

Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>

* remove workaround for python-poetry/poetry#4210

Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>

* skip win + pypy3 builds due to python-poetry/poetry#4626

Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>

* drop 3.6 jobs

Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>

Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
@operte
Copy link

operte commented Oct 30, 2022

I just had the same issue. I tried first deleting the virtual environment (as per @jamesowers-roo), but that didn't fix it.

What worked was the solution from @hoefling:

BTW disabling poetry's experimental new installer may be a workaround for now:

$ poetry config experimental.new-installer false

@neersighted
Copy link
Member

The JSONDecodeError discussed here is very specifically related to cache-control. Other JSONDecodeErrors are likely caused by broken systems/virtual environments and are more general (not Windows) versions of #6664.

luabida added a commit to luabida/PySUS that referenced this issue Feb 3, 2023
esloch pushed a commit to AlertaDengue/PySUS that referenced this issue Feb 3, 2023
* feat(semantic-release): add semantic release to the project

* Add test release to workflow

* fix typo

* Fix HEAD branch name

* Force node version to 18 on release.yaml

* fix poetry on ci according to python-poetry/poetry#4210

* Adding back dbf to fix tests

* Skipping sids dbc test
@dimbleby dimbleby mentioned this issue Mar 24, 2023
4 tasks
malor added a commit to malor/cpython-lldb that referenced this issue May 24, 2023
This was required to make the new poetry release work on Python 3.10,
but not anymore. See python-poetry/poetry#4210
for detail.
malor added a commit to malor/cpython-lldb that referenced this issue May 24, 2023
This was required to make the new poetry release work on Python 3.10,
but not anymore. See python-poetry/poetry#4210
for details.
Copy link

github-actions bot commented Mar 1, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests