<#21697 ModuleNotFoundError: No module named 'dist...
# github-notifications
c
#21697 ModuleNotFoundError: No module named 'distutils.util' Issue created by mdaffad Describe the bug I tried to run
pants generate-lockfiles
, and the following error message appeared:
Copy code
pip:   File "/home/***/.cache/pants/named_caches/pex_root/venvs/***/lib/python3.10/site-packages/pip/_vendor/packaging/tags.py", line 7, in <module>
pip:     import distutils.util
pip: ModuleNotFoundError: No module named 'distutils.util'
After debugging, I found that it uses Python 3.10 from the /usr/bin path because I installed a Python interpreter that fulfills the interpreter constraints. I tried to resolve this by updating the search path to
search_path = ["<PYENV>", "<PYENV_LOCAL>"]
and setting
interpreter_constraints = ['>=3.10-dev,<3.12-dev']
. My goal is to use the Python interpreter installed via pyenv, which includes the distutils package. I installed the interpreter with the
3.10-dev
version. My question: 1. Is the interpreter selection determined by the lowest fulfilled version available in the search_path? For example:
intepreter_constraints = ['>=3.10,<3.12']
search_path = ["<PYENV_LOCAL>", "/usr/bin"]
2. How can I properly define interpreter_constraints for a
<major>.<minor>-dev
version? When I use
interpreter_constraints = ['>=3.10-dev,<3.12-dev']
, it works without error, but there is no documentation explaining how to specify constraints for
<major>.<minor>-dev
. Note: 1. I verified the constraint by adding version 3.10 via pyenv (without the -dev suffix), but it still properly selects the interpreter with -dev. 2. I checked if the distutils import works by running import distutils.util on the interpreter that was exported using pants export. Pants version 2.23.0 OS Ubuntu 20.04 Additional info May relevant information on python and python-bootstrap configuration Old pants.toml
Copy code
...
[python]
interpreter_constraints = ['>=3.10,<3.12']
...
[python-bootstrap]
search_path = ["<PYENV_LOCAL>", "/usr/bin"]
New pants.toml
Copy code
...
[python]
interpreter_constraints = ['>=3.10-dev,<3.12-dev']
enable_resolves = true

[python-bootstrap]
search_path = ["<PYENV>", "<PYENV_LOCAL>"]
pantsbuild/pants