https://pantsbuild.org/ logo
#general
Title
# general
b

big-agency-50572

02/17/2023, 11:39 AM
Hi there. When I try to run
./pants package ::
I'm receiving the following Python exception:
Copy code
13:37:08.36 [INFO] Completed: Building dockerfile_parser.pex from dockerfile-parser_default.lock
13:37:08.36 [ERROR] 1 Exception encountered:

  ProcessExecutionFailure: Process 'Building dockerfile_parser.pex from dockerfile-parser_default.lock' failed with exit code 1.
stdout:

stderr:
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.8/runpy.py", line 86, in _run_code
    exec(code, run_globals)

  ProcessExecutionFailure: Process 'Building dockerfile_parser.pex from dockerfile-parser_default.lock' failed with exit code 1.
...
ModuleNotFoundError: No module named '_sqlite3'
Pants bootstrapped with Python 3.9, but the the above traceback shows that Pants is using Python 3.8 when I run it. This normally wouldn't be a problem, but my system default (3.8) doesn't include sqlite3. Any idea how to get around this and force Pants to use 3.9, which does include sqlite3?
Alright I've managed to figure this out, seems to be specific to
dockerfile_parser.pex
. My solution was to force the
interpreter_constraints
to
"CPython>=3.9,<4"
via the
PANTS_DOCKERFILE_PARSER_INTERPRETER_CONSTRAINTS
env var, as per the docs.
PANTS_DOCKERFILE_PARSER_INTERPRETER_CONSTRAINTS='["CPython>=3.9,<4"]' ./pants package ::
runs successfully.
Not sure why it was defaulting to 3.8, perhaps a bug?
f

fresh-cat-90827

02/17/2023, 12:38 PM
Fwiw you may want to use a python interpreter that's coming with pyenv instead of using the default system one, it has lower chances to cause compatibility related issues
👍 1
e

enough-analyst-54434

02/17/2023, 2:36 PM
Not sure why it was defaulting to 3.8, perhaps a bug?
@big-agency-50572 what do you have the interpreter constraints for the repo configured as in
pants.toml
? The Python Pants bootstraps with is a detail (pretend for a moment Pants is written in JS + Rust instead of Python + Rust) and it's completely unrelated to the Python it picks to run your code with when you happen to be using Pants Python support. The default interpreter constraints Pants ships with for Python projects (Pants should offer no default and force you to set this!) is
>=3.7,<4
.
b

big-agency-50572

02/20/2023, 12:57 PM
@enough-analyst-54434 Thank you, I'm actually not using the Python support at all yet and am only using Pants for Docker builds currently. I've removed Python 3.8 entirely from my system and after a reboot my original issue is no longer occurring (even without setting the
PANTS_DOCKERFILE_PARSER_INTERPRETER_CONSTRAINTS
). Thanks so much for the replies 🙂