big-agency-50572
02/17/2023, 11:39 AM./pants package ::
I'm receiving the following Python exception:
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?big-agency-50572
02/17/2023, 12:20 PMdockerfile_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.big-agency-50572
02/17/2023, 12:21 PMPANTS_DOCKERFILE_PARSER_INTERPRETER_CONSTRAINTS='["CPython>=3.9,<4"]' ./pants package ::
runs successfully.big-agency-50572
02/17/2023, 12:22 PMfresh-cat-90827
02/17/2023, 12:38 PMenough-analyst-54434
02/17/2023, 2:36 PMNot 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
.big-agency-50572
02/20/2023, 12:57 PMPANTS_DOCKERFILE_PARSER_INTERPRETER_CONSTRAINTS
). Thanks so much for the replies 🙂