poetry: JSONDecodeError on Python 3.10
-
I am on the latest Poetry version.
-
I have searched the issues of this repo and believe that this is not a duplicate.
-
If an exception occurs when executing a command, I executed it again in debug mode (
-vvv
option). -
OS version and name: macOS 11.4
-
Poetry version: 1.1.6
-
Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/robd003/9147c6ec95678bd578b6da828f1b3840
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│
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 56
- Comments: 40 (12 by maintainers)
Commits related to this issue
- Update Poetry installs for install-poetry.py 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 ol... — committed to br3ndonland/fastenv by br3ndonland 3 years ago
- CI: Disable Poetry's new installer on 3.10 Works around https://github.com/python-poetry/poetry/issues/4210 — committed to remram44/taguette by remram44 3 years ago
- Fixed poetry install error in python3.10, https://github.com/python-poetry/poetry/issues/4210 — committed to abersheeran/baize by abersheeran 3 years ago
- poetry's new installer does not support python 3.10 yet, see https://github.com/python-poetry/poetry/issues/4210 — committed to venth/aws-adfs by pdecat 3 years ago
- Disable Poetry experimental new installer python-poetry/poetry#3811 python-poetry/poetry#4210 Poetry installs are erroring with `JSONDecodeError`s in GitHub Actions: ```text poetry install --no-int... — committed to br3ndonland/fastenv by br3ndonland 3 years ago
- Disable Poetry experimental new installer python-poetry/poetry#3811 python-poetry/poetry#4210 Poetry installs are erroring with `JSONDecodeError`s in GitHub Actions: ```text poetry install --no-int... — committed to br3ndonland/inboard by br3ndonland 3 years ago
- Disable Poetry experimental new installer python-poetry/poetry#3811 python-poetry/poetry#4210 Poetry installs are erroring with `JSONDecodeError`s in GitHub Actions: `poetry cache clear --all pypi ... — committed to br3ndonland/template-python by br3ndonland 3 years ago
- fix: upgrade Poetry version to workaround issue between Poetry and Python 3.10 (see: https://github.com/python-poetry/poetry/issues/4210) Signed-off-by: Paul Horton <phorton@sonatype.com> — committed to CycloneDX/cyclonedx-python-lib by madpah 3 years ago
- FEAT: Support Python 3.10 (#64) * fix: tested with Python 3.10 Signed-off-by: Paul Horton <phorton@sonatype.com> * added trove classifier for Python 3.10 Signed-off-by: Paul Horton <phorton@... — committed to CycloneDX/cyclonedx-python-lib by madpah 3 years ago
- update poetry install action to newer version https://github.com/python-poetry/poetry/issues/4210 — committed to stereobutter/reddish by stereobutter 3 years ago
- update poetry install action to newer version https://github.com/python-poetry/poetry/issues/4210 — committed to stereobutter/reddish by stereobutter 3 years ago
- update poetry install action to newer version https://github.com/python-poetry/poetry/issues/4210 — committed to stereobutter/reddish by stereobutter 3 years ago
- [poetry] Try to fix JSONDecodeError. https://github.com/python-poetry/poetry/issues/4210 — committed to ufz/ogs by bilke 2 years ago
- remove workaround for python-poetry/poetry#4210 Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com> — committed to hoefling/devpi-client-extensions by hoefling 2 years ago
- remove workaround for python-poetry/poetry#4210 Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com> — committed to hoefling/devpi-client-extensions by hoefling 2 years ago
- don't run the ci twice per each pull request (#72) * 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 Si... — committed to hoefling/devpi-client-extensions by hoefling 2 years ago
- fix poetry on ci according to https://github.com/python-poetry/poetry/issues/4210 — committed to luabida/PySUS by luabida a year ago
- feat(semantic-release): add semantic release to the project (#114) * feat(semantic-release): add semantic release to the project * Add test release to workflow * fix typo * Fix HEAD branch n... — committed to AlertaDengue/PySUS by luabida a year ago
- Remove poetry installer overrides This was required to make the new poetry release work on Python 3.10, but not anymore. See https://github.com/python-poetry/poetry/issues/4210 for detail. — committed to malor/cpython-lldb by malor a year ago
- Remove poetry installer overrides This was required to make the new poetry release work on Python 3.10, but not anymore. See https://github.com/python-poetry/poetry/issues/4210 for details. — committed to malor/cpython-lldb by malor a year ago
BTW disabling
poetry
’s experimental new installer may be a workaround for now:Reproducible with 3.10 on Linux & Windows as well.
Here’s how to fix it:
did the trick. For me which python version it run on seemed irrelevant.
So, the issue is resolved with the new version of cachecontrol==0.12.9 (it will be installed automatically).
Besides, when trying to reproduce this bug in a fresh container I see “SolverProblemError”, thus, after this update some of the issues with that error could be resolved as well.
How to reproduce:
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:
Fails:
Poetry eats most of the stack trace. I see the following repeated once for each dependency:
Removing the Poetry cache with
rm -r ~/.cache/pypoetry/cache/
orm -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.This issue also occurs on Python3.6 with:
The two workarounds mentioned in this ticket work:
poetry config experimental.new-installer false
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.
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?
fresh install with install-poetry.py, deleting poetry.lock, and latest version of cachecontrol did not fix the issue for me, FYI
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 thecachecontrol
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 ofcachecontrol
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
Try installing CacheControl==0.12.6 or wait for https://github.com/ionrock/cachecontrol/pull/264
What happens:
What happens when you disable experimentail installer - the same thing as running
poetry update
second time. Cache was updated at step 3, so, installation process continues to the next stale item.I can confirm that the issue is resolved by @hoefling’s suggestion.
Anyone got this on 3.9.7? I get
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
I use
rm -rf ~/.cache/pypoetry/cache/
.The error is resolved with
experimental.new-installer false
every time.With
experimental.new-installer true
, sometimes the errorJSONDecodeError
is raised and it works in next attempt without changingexperimental.new-installer
value. I guess it matches with ddc67cd’s comment.I tested with:
pyproject.toml
file:It can fail with other dependencies than Markdown.
There was a
poetry.toml
file during the tests but I don’t think it’s relevant:Came here to say it started happening out of nowhere on poetry 1.1.11 with python 3.8.12 on github actions ubuntu 20.04 when I added beautifulsoup4 as a dev dependency. No idea what makes that package special, I cleared the cache in the meantime.
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):
This looks to be related to https://github.com/pypa/setuptools/issues/2957. Presumably I had broken my venv via various installations.
So my advice if you get a
JSONDecodeError
withpoetry
is to simply executepython
, 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
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
I run into this issue on Python 3.8.8 as well.
I’ll try to see if I can give you a minimal repro, but for me it started happening after the bs4 package was added and the cache from a previous github actions run was used.
Edit : it is run in a container based on ubuntu 20.04 where python is installed thanks to the setup python action. Poetry is installed with pip