How does pants find its version of python? I use a...
# general
b
How does pants find its version of python? I use asdf and have 3.10.11, 3.11.3, and 3.12 installed. I also happen to have 3.11.6 installed via Homebrew (from before I used asdf). Right now I use asdf to set python to 3.12. My pants.toml specifies anything from >=3.11. For some reason, pants always latch on to the 3.11.6 in Homebrew, so that when I export the venv, VS code gets very confused and can't find the venv at all, and none of the packages used in the repo is detected.
n
It uses the paths configured using this option: https://www.pantsbuild.org/docs/reference-python-bootstrap#search_path
I reckon adding
<ASDF>
will get you closer to your goal.
b
Do I add that to pants.toml?
n
Yep! E.g.
Copy code
[python-bootstrap]
search_path = ["<ASDF>"]
b
Progress! But now this error:
Copy code
Interpreters were found but they all appear to be broken:
1.) /Users/joe/.asdf/installs/python/3.12.0/bin/python3.12:
Traceback (most recent call last):
  File "<string>", line 4, in <module>
  File "/Users/joe/.cache/pants/named_caches/pex_root/isolated/3754108aac57ec0c996f3414782585924aee601c/pex/atomic_directory.py", line 23, in <module>
    from pex.third_party import attr
ImportError: cannot import name 'attr' from 'pex.third_party' (/Users/joe/.cache/pants/named_caches/pex_root/isolated/3754108aac57ec0c996f3414782585924aee601c/pex/third_party/__init__.py)

(See <https://github.com/pantsbuild/pex/issues/1027> for a list of known breaks and workarounds.)
n
Seems like PEX does not support Py 3.12 until 2.1.139. Not sure which version of PEX your Pants version uses.
c
pants is not yet using 2.1.139, latest
main
is still on
.137
. You can upgrade manually by updating the corresponding options in your
pants.toml
to tell pants to use a newer version.
b
Thanks.
I can fall back to 3.11 for now. My biggest struggle is with VS Code finding the generated venv.
c