Hi all, hope this is a qq, I got an error `Could n...
# general
j
Hi all, hope this is a qq, I got an error
Could not find a compatible interpreter.
when running a python source. It seems like pants did find the interpreter defined in PYENV, but skipped them for some reasons
Copy code
Examined the following working interpreters:
1.)/Users/xx/.pyenv/versions/3.7.16/bin/python3.7 CPython==3.7.16
...
Skipped the following broken interpreters:
1.) /Users/xx/.pyenv/shims/python3.7:
pyenv: python3.7: command not found

The `python3.7' command exists in these Python versions:
  3.7.16

Note: See 'pyenv help global' for tips on allowing both
      python2 and python3 to be found.
e
What happens when you run the path listed yourself?
j
it works
Copy code
/Users/xx/.pyenv/shims/python3.7 --version
Python 3.7.16
e
c
Copy code
pyenv: python3.7: command not found
this means that you don’t have an “selected” version of python3.7, however the next lines tells you there is one installed. https://github.com/pyenv/pyenv#switch-between-python-versions
j
I reinstalled with specific number pyenv install 3.7.16, now it seems like it’s not skipped, but still got error
Copy code
ProcessExecutionFailure: Process 'Find interpreter for constraints: CPython==3.10.9,==3.7.*' failed with exit code 102.
stdout:

stderr:
Could not find a compatible interpreter.

Examined the following working interpreters:
1.)                                                /Users/xx/.pyenv/versions/3.7.16/bin/python3.7 CPython==3.7.16
2.)                                               /Users/xx/.pyenv/versions/3.10.9/bin/python3.10 CPython==3.10.9
3.)                                                /Users/xx/.pyenv/versions/3.8.16/bin/python3.8 CPython==3.8.16
4.)  /opt/homebrew/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/bin/python3.11 CPython==3.11.2
5.) /opt/homebrew/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/bin/python3.10 CPython==3.10.10
6.)       /opt/homebrew/Cellar/python@3.9/3.9.16/Frameworks/Python.framework/Versions/3.9/bin/python3.9 CPython==3.9.16
7.) /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/bin/python3.9 CPython==3.9.6

Skipped the following broken interpreters:
1.) /Users/xx/.pyenv/shims/python3.8:
pyenv: python3.8: command not found

The `python3.8' command exists in these Python versions:
  3.8.16
Copy code
/Users/xx/.pyenv/versions/3.7.16/bin/python3.7 --version
Python 3.7.16
e
The comma operator means AND, so your interpreter constraints are impossible to satisfy.
Can you describe what interpreters you intend?
j
oh, interesting this is what I used for one specific python project
Copy code
python_source(
    name="dev",
    source="main.py",
    run_goal_use_sandbox=False,
    resolve="ai",
    interpreter_constraints=["==3.7.*"],
    dependencies=[":alignment"],
)
python_sources(
    name="alignment"
    resolve="ai",
)
and this is the settings in pants.toml
Copy code
[python]
interpreter_constraints = ["CPython==3.10.9"]
enable_resolves = true
default_resolve = "python-default"

[python.resolves_to_interpreter_constraints]
ai = ["==3.7.*"]
oh, I think I know what went wrong
I think it’s the dependencies, let me fix that
yeah, after adding the
interpreter_constraints=["==3.7.*"],
to the dependencies, that fixed the issue. Thank you!