Poetry: JSONDecodeError

Created on 20 Nov 2018  路  8Comments  路  Source: python-poetry/poetry

  • [x] I am on the latest Poetry version.
  • [x] I have searched the issues of this repo and believe that this is not a duplicate.
  • [x] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: macOS Mojave 10.14
  • Poetry version: 0.12.9
    pyproject.toml file:
位 cat pyproject.toml
[tool.poetry]
name = "pixiv2bg"
version = "1.0.0"
description = "Pixiv pictures to background."
authors = ["Nasy"]
license = "MIT"

[tool.poetry.dependencies]
uvloop = "^0.11.1"
aiohttp = "^3.3"
tqdm = "^4.24"
ujson = "^1.35"

[tool.black]
line-length = 79

Issue

Well, when doing poetry install, an exception happened. I also have tried to remove the pyproject.toml and poetry init again, but it still failed like the result shown below.

The project is here: https://github.com/nasyxx/pixiv2bg . Simply clone it down and poetry install, the exception will raise.

Here is the result:

位 poetry install -vvv                  
[JSONDecodeError]             
Expecting value: line 1 column 1 (char 0)  

Exception trace:
 /usr/local/lib/python3.7/site-packages/cleo/application.py in run() at line 94
   status_code = self.do_run(input_, output_)
 /usr/local/lib/python3.7/site-packages/poetry/console/application.py in do_run() at line 88
   return super(Application, self).do_run(i, o)
 /usr/local/lib/python3.7/site-packages/cleo/application.py in do_run() at line 197
   status_code = command.run(input_, output_)
 /usr/local/lib/python3.7/site-packages/poetry/console/commands/command.py in run() at line 77
   return super(BaseCommand, self).run(i, o)
 /usr/local/lib/python3.7/site-packages/cleo/commands/base_command.py in run() at line 136
   self.initialize(input_, output_)
 /usr/local/lib/python3.7/site-packages/poetry/console/commands/env_command.py in initialize() at line 21
   ".".join(str(v) for v in current_env.version_info[:3])
 /usr/local/lib/python3.7/site-packages/poetry/utils/env.py in version_info() at line 128
   return tuple(self.marker_env["version_info"])
 /usr/local/lib/python3.7/site-packages/poetry/utils/env.py in marker_env() at line 144
   self._marker_env = self.get_marker_env()
 /usr/local/lib/python3.7/site-packages/poetry/utils/env.py in get_marker_env() at line 466
   return json.loads(output)
 /usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/__init__.py in loads() at line 348
   return _default_decoder.decode(s)
 /usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py in decode() at line 337
   obj, end = self.raw_decode(s, idx=_w(s, 0).end())
 /usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py in raw_decode() at line 355
   raise JSONDecodeError("Expecting value", s, err.value) from None

install [--no-dev] [--dry-run] [-E|--extras EXTRAS] [--develop DEVELOP]

Most helpful comment

for me at least https://github.com/sdispater/poetry/issues/779 seems to be the root cause. EnvBuilder create fails to copy files for some reason and leaves a partially created and nonfunctional venv. How it fails I'm not clear on yet. However at least on my system I have a consistent repro by doing this ( code modeled on utils/env.py )

tmpdir = tempfile.mkdtemp()
path = pathlib.Path( tmpdir ) / "test"
print(f"creating temp dir in {path}")
builder = EnvBuilder(with_pip=True)
builder.create(path)

which gives this error

 output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['/usr/tmp/tmp2lefjc9x/testp/bin/python', '-Im', 'ensurepip', '--upgrade', '--default-pip']' died with <Signals.SIGABRT: 6>.

but it works if I flip the mode to use symlinks

builder = EnvBuilder(with_pip=True, symlinks=True)

and that also works after patching env.py in poetry.

note - that you only see this error on the first command that triggers venv creation. Subsequent commands will call get_marker_env() that shells out to the python in the broken venv and gets an error string instead of a valid json block - triggering the JSONDecodeError error above.

All 8 comments

Hi, I guess I have solved this issue. I deleted the cache file and it works well again.

I'm seeing this same issue - on Linux. And cache delete appears not to help.

Also bumped into this. What is causing this?

$ poetry debug:info

Poetry
======

 * Version: 0.12.12
 * Python:  3.7.3



[JSONDecodeError]             
Expecting value: line 1 column 1 (char 0)  

debug:info


$ poetry -vvv shell

[JSONDecodeError]             
Expecting value: line 1 column 1 (char 0)  

Exception trace:
 /home/jupiter/.poetry/lib/poetry/_vendor/py3.7/cleo/application.py in run() at line 94
   status_code = self.do_run(input_, output_)
 /home/jupiter/.poetry/lib/poetry/console/application.py in do_run() at line 88
   return super(Application, self).do_run(i, o)
 /home/jupiter/.poetry/lib/poetry/_vendor/py3.7/cleo/application.py in do_run() at line 197
   status_code = command.run(input_, output_)
 /home/jupiter/.poetry/lib/poetry/console/commands/command.py in run() at line 77
   return super(BaseCommand, self).run(i, o)
 /home/jupiter/.poetry/lib/poetry/_vendor/py3.7/cleo/commands/base_command.py in run() at line 136
   self.initialize(input_, output_)
 /home/jupiter/.poetry/lib/poetry/console/commands/env_command.py in initialize() at line 21
   ".".join(str(v) for v in current_env.version_info[:3])
 /home/jupiter/.poetry/lib/poetry/utils/env.py in version_info() at line 128
   return tuple(self.marker_env["version_info"])
 /home/jupiter/.poetry/lib/poetry/utils/env.py in marker_env() at line 144
   self._marker_env = self.get_marker_env()
 /home/jupiter/.poetry/lib/poetry/utils/env.py in get_marker_env() at line 457
   return json.loads(output)
 /usr/local/lib/python3.7/json/__init__.py in loads() at line 348
   return _default_decoder.decode(s)
 /usr/local/lib/python3.7/json/decoder.py in decode() at line 337
   obj, end = self.raw_decode(s, idx=_w(s, 0).end())
 /usr/local/lib/python3.7/json/decoder.py in raw_decode() at line 355
   raise JSONDecodeError("Expecting value", s, err.value) from None

shell

This is on a docker image FROM python:3.7 which defined some ENV values:

$ env
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
LANG=C.UTF-8
HOSTNAME=c6139831b503
GPG_KEY=0D96DF4D4110E5C43FBFB17F2D347EA6AA65421D
PWD=/usr/src/app
HOME=/home/jupiter
TERM=xterm
PYTHON_VERSION=3.7.3
SHLVL=1
PATH=/home/jupiter/.poetry/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PYTHON_PIP_VERSION=19.0.3
_=/usr/bin/env

for me at least https://github.com/sdispater/poetry/issues/779 seems to be the root cause. EnvBuilder create fails to copy files for some reason and leaves a partially created and nonfunctional venv. How it fails I'm not clear on yet. However at least on my system I have a consistent repro by doing this ( code modeled on utils/env.py )

tmpdir = tempfile.mkdtemp()
path = pathlib.Path( tmpdir ) / "test"
print(f"creating temp dir in {path}")
builder = EnvBuilder(with_pip=True)
builder.create(path)

which gives this error

 output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['/usr/tmp/tmp2lefjc9x/testp/bin/python', '-Im', 'ensurepip', '--upgrade', '--default-pip']' died with <Signals.SIGABRT: 6>.

but it works if I flip the mode to use symlinks

builder = EnvBuilder(with_pip=True, symlinks=True)

and that also works after patching env.py in poetry.

note - that you only see this error on the first command that triggers venv creation. Subsequent commands will call get_marker_env() that shells out to the python in the broken venv and gets an error string instead of a valid json block - triggering the JSONDecodeError error above.

I have the exact same issue.
Clearing the cache did not work for me.
Python version: Python 3.7.3

@spebern - even with the latest Poetry version ? does a simple .venv/bin/python work as expected ?

I get errors that libc is missing using python:3.7-slim-stretch:

# .venv/bin/python
.venv/bin/python: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.25' not found (required by .venv/bin/python)
.venv/bin/python: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.26' not found (required by .venv/bin/python)

If I run apt-get install libc6, blow away .venv and re-run poetry install, everything works.

_Edit_: welp, turns out my problem's problem was that .venv was not in my .dockerignore. That seems to have sorted me out for real this time.

As per #779, I was able to get around this python -m venv .venv on my Mac with version 10.14.6

Was this page helpful?
0 / 5 - 0 ratings