Hi, I'm trying to run pants with python 3.13 and I...
# general
c
Hi, I'm trying to run pants with python 3.13 and I'm getting the error
Copy code
ProcessExecutionFailure: Process 'Find interpreter for constraints: CPython==3.13.*' failed with exit code 1.
stdout:

stderr:
No supported version of Pip is compatible with the given targets
...
do I need to fix or otherwise specify a version/version range for pip or is this a symptom of something else?
âś… 1
b
What version of Pants are you running?
c
2.22.0
b
Gotcha. You may need to update the version of PEX in your
pants.toml
to the latest version - that should support the latest Pip + Python 3.13: https://www.pantsbuild.org/2.21/reference/subsystems/pex-cli
It looks like support for Python 3.13 was first added in PEX version 2.5.0: https://github.com/pex-tool/pex/releases/tag/v2.5.0 But Pants 2.22 uses PEX 2.3.1 by default
c
It looks like actually it might be a
PATH
issue, when I run
pants lint
even when specifying 3.12 instead, I get the same error but it mentions all installed versions of python on my system. I'm wondering if the 3.13 install could have done something more than just add the latest version to the
PATH
🤦 any ideas would be great, I think the issue I'm having is getting in the way before I even get to the issue you mention!
b
Can you paste in the error that you get when trying to run
pants lint
with 3.12?
c
Sure, here it is:
Copy code
Engine traceback:
  in `lint` goal

ProcessExecutionFailure: Process 'Find interpreter for constraints: CPython<4,>=3.7' failed with exit code 1.
stdout:

stderr:
No supported version of Pip is compatible with the given targets:
cp310-cp310-macosx_14_0_arm64 interpreter at /Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10
cp311-cp311-macosx_14_0_arm64 interpreter at /Library/Frameworks/Python.framework/Versions/3.11/bin/python3.11
cp312-cp312-macosx_14_0_arm64 interpreter at /Users/mkahan/Development/vonage-python-sdk/venv-edit/bin/python3.12
cp313-cp313-macosx_14_0_arm64 interpreter at /Library/Frameworks/Python.framework/Versions/3.13/bin/python3.13
cp37-cp37m-macosx_14_0_x86_64 interpreter at /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7
cp39-cp39-macosx_14_0_arm64 interpreter at /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/bin/python3.9
b
Hmm yeah, I think this has to do with your interpreter constraints; there is no version of Pip that is compatible with both Python 3.7 and 3.13. See here for more details: https://github.com/pantsbuild/pants/issues/21103 Try setting your upper bound to 3.12 instead, and seeing if that works, so:
Copy code
CPython<=3.12,>=3.7
c
My interpreter constraints looks like this:
Copy code
[python]
interpreter_constraints = ['==3.12.*']
b
Hmm, is that being overridden somewhere? Because the output contains:
Copy code
Process 'Find interpreter for constraints: CPython<4,>=3.7' failed with exit code 1.
c
Not that I can see, no....
in my
[coverage-py]
block I have
interpreter_constraints = ['>=3.9']
but that should be just for coverage
b
What does your lockfile say? It should contain something like this at the top:
Copy code
// This lockfile was autogenerated by Pants. To regenerate, run:
//
//    pants generate-lockfiles --resolve=python-default
//
// --- BEGIN PANTS LOCKFILE METADATA: DO NOT EDIT OR REMOVE ---
// {
//   "version": 3,
//   "valid_for_interpreter_constraints": [
//     "CPython<3.13,>=3.12"
//   ],
c
I don't have a lockfile generated for my monorepo, running the command in yours produces no output
Strangely, it runs my tests correctly when I do
pants test ::
but also shows the error
b
Okay. And what tool are you trying to run with the
pants lint
command?
c
autoflake, black, isort, docformatter and taplo. I think it fails when it hits docformatter
Copy code
13:31:32.19 [INFO] Completed: Format with taplo - taplo made no changes.
13:31:32.20 [INFO] Canceled: Building docformatter.pex from <resource://pants.backend.python.lint.docformatter/docformatter.lock>
13:31:33.40 [ERROR] 1 Exception encountered:
actually no it fails after taplo, what it fails on is different each time
Just ran it again and it failed on black
b
You may want to set the interpreter constraints for docformatter then: https://www.pantsbuild.org/stable/reference/subsystems/docformatter#interpreter_constraints That same option is available for autoflake, black, and isort as well (but not taplo)
c
This was all working perfectly until I installed Python 3.13 today, it would be good to understand what might have been changed
It looks like the error is saying that none of my python interpreters will work with pants, which is why I think something is wrong
b
Probably https://pantsbuild.slack.com/archives/C046T6T9U/p1728390186031419?thread_ts=1728386679.902609&cid=C046T6T9U. You only had Python 3.7-3.12 installed before that, so Pip was able to support all Pythons in that range just fine. Now that you installed 3.13 you’ll need to set a minimum of 3.8 for all tools to make Pip work nicely, as Pip cannot support both 3.7 and 3.13 at once. It sounds like you don’t need 3.7 support anyway, so I would recommend using a constraint of
>=3.8
for most of the tools.
c
I set all the tools to have constraints >=3.12, and I still get this error:
Copy code
ProcessExecutionFailure: Process 'Find interpreter for constraints: CPython>=3.12' failed with exit code 1.
stdout:

stderr:
No supported version of Pip is compatible with the given targets:
cp312-cp312-macosx_14_0_arm64 interpreter at /Users/mkahan/Development/venv-edit/bin/python3.12
cp313-cp313-macosx_14_0_arm64 interpreter at /Library/Frameworks/Python.framework/Versions/3.13/bin/python3.13
b
Now, you will probably need to upgrade the PEX version as I mentioned in the OP - you can bump to the version used in Pants 2.23: https://www.pantsbuild.org/prerelease/reference/subsystems/pex-cli
c
I tried it and got
Copy code
UnsupportedVersion: The option [pex-cli].version is set to >=2.16.2, which is not compatible with what this release of Pants expects: pex<3.0,>=2.3.0. Please update the version to a supported value, or consider using a different Pants release if you cannot change the version. Alternatively, update [pex-cli].use_unsupported_version to be 'warning'.
b
You have to set that to a specific version, not a range specifier: https://www.pantsbuild.org/prerelease/reference/subsystems/pex-cli#version
c
Oh my bad, I'll try that
b
I would recommend reading through the docs for all of the
[pex-cli]
options before trying to set them
c
Will do that now
Okay, setting it what I think it correctly gives me this output:
Copy code
UnknownVersion: No known version of pex 2.16.2 for macos_arm64 found in ('v2.3.1|macos_arm64|71690e672871b55323f5d6ef9a3fe9705f1668662652c4081080e7ab27d44de3|4124530', 'v2.3.1|macos_x86_64|71690e672871b55323f5d6ef9a3fe9705f1668662652c4081080e7ab27d44de3|4124530', 'v2.3.1|linux_x86_64|71690e672871b55323f5d6ef9a3fe9705f1668662652c4081080e7ab27d44de3|4124530', 'v2.3.1|linux_arm64|71690e672871b55323f5d6ef9a3fe9705f1668662652c4081080e7ab27d44de3|4124530')
b
Right, you’ll need to override the
known_versions
as well so that it contains the version and hash for the platform that you’re trying to use. PEX 2.16.2's values can be found here: https://www.pantsbuild.org/prerelease/reference/subsystems/pex-cli#known_versions
c
I copied the values and it's still unable to find it!
Copy code
UnknownVersion: No known version of pex 2.16.2 for macos_arm64 found in ('v2.16.2|macos_arm64|f2ec29dda754c71a8b662e3b4a9071aef269a9991ae920666567669472dcd556|4284448', 'v2.16.2|macos_x86_64|f2ec29dda754c71a8b662e3b4a9071aef269a9991ae920666567669472dcd556|4284448', 'v2.16.2|linux_x86_64|f2ec29dda754c71a8b662e3b4a9071aef269a9991ae920666567669472dcd556|4284448', 'v2.16.2|linux_arm64|f2ec29dda754c71a8b662e3b4a9071aef269a9991ae920666567669472dcd556|4284448')
b
Try including the
v
in the version name
c
So when I run this with v3.12, it fixes the behaviour! Thanks, that gets me back to being able to develop. Though when I set the interpreter constraints to 3.13, I still get
Copy code
The Pip requested was pip==24.0 but it does not work with the interpreter selected which is CPython 3.13.0 at /Library/Frameworks/Python.framework/Versions/3.13/bin/python3.13. Pip 24.0 requires Python <3.13,>=3.7.
What's requesting that pip version?
b
I believe Pants does, you can override that to 24.2 (the version supporting Python 3.13) here: https://www.pantsbuild.org/prerelease/reference/subsystems/python#pip_version
c
I think that the original issue would have been my interpreter constraints for the
coverage-py
tool being >=3.8, so it was implicitly covering a version range including 3.13
b
No, that actually was fine - the issue is only when you try to cover 3.7 and 3.13 together. The error message you got was because the default version range for most tools used to be
>=3.7, <4
(we fixed this in Pants 2.24)
c
I tried to set
pip_version = 'latest'
but that didn't work. I tried
pip_version = '24.2'
explicitly but still got the error:
Copy code
The Pip requested was pip==24.0 but it does not work with the interpreter selected which is CPython 3.13.0 at /Library/Frameworks/Python.framework/Versions/3.13/bin/python3.13. Pip 24.0 requires Python <3.13,>=3.7.
The error message you got was because the default version range for most tools used to be
>=3.7, <4
(we fixed this in Pants 2.24)
Oh that's interesting context
b
PEX added support for Pip 24.2 in release 2.13.0: https://github.com/pex-tool/pex/releases/tag/v2.13.0 So PEX 2.16.2 should definitely support it as well. Are you sure you set
pip_version = '24.2'
in the right section of the config?
c
It's under the python section:
Copy code
[python]
interpreter_constraints = ['==3.13.*']
pip_version = '24.2'
b
Hmm okay, that seems all right. Not sure why it’s still using 24.0 for you
c
I could upgrade to 2.23 but I guess that's the same PEX version so would require the same pip?
b
Yeah, I don’t think you’d gain much benefit from upgrading to 2.23, most of the changes that address this specific issue are in 2.24, ex: https://github.com/pantsbuild/pants/pull/21400
c
I upgraded to 2.24.0dev0 and tests worked, as did most of the linting, but
docformatter
had an error
ModuleNotFoundError: No module named 'lib2to3'
I assume it's not stable yet so not really possible for me to use python 3.13 just yet?
b
I haven’t tried using Python 3.13 yet, and it looks like that particular dependency (part of the standard library) was removed in 3.13: https://github.com/python/cpython/issues/104780
I suspect there are going to be other cases of silent breakage in tools based on standard library / other things being removed, so use 3.13 at your own risk
c
Yep, seems very reasonable. I'll definitely keep that in mind.
Thanks for your time Krishnan, it's been very useful and also very interesting to learn more about pants in the process!
b
All good! Glad to be of help
🎉 1
❤️ 1
b
Adding on to this thread - I faced the same issue today. • My pants.toml had
interpreter_constraints = ["CPython==3.11.*"]
and
pants_version = "2.21.0"
• Got python 3.13 installed automatically while running a humble
brew upgrade
(iirc,
isort
added that as dependency) • The entire thing wrecked havoc. • Simple forced uninstall of python3.13 fixed the issue right back. • If I understand correctly, ideally I should not have faced this with a hard constraint on 3.11.*
b
If I understand correctly, ideally I should not have faced this with a hard constraint on 3.11.*
The real issue is the tool lockfiles, which used to have constraints of `>=3.7,<4`: https://pantsbuild.slack.com/archives/C046T6T9U/p1728392666402449?thread_ts=1728386679.902609&amp;cid=C046T6T9U. You Even though you have 3.11 set in your interpreter constraints, I believe what’s happening here might be that the tool is run with Python 3.13 due to the constraints in the lockfile. Depending on what tool you try to run, you should be able to set its
interpreter_constraints
as well (ex: for Black) to avoid this issue.
b
I had the exact same problem today. My pants.toml file specifically locks pants to 2.20.0 and python to 3.10.12. The fix was: brew uninstall python@3.13 - which I installed by running brew upgrade