pythonpants

Pants unable to bootstrap because Invalid Python interpreter version


I'm trying to setup a Java project using Pants in Linux — specifically Arch Linux.

I'm following the documentation to just install it, but I'm always getting an error when running ./pants --version:

$ ./pants --version 
Invalid Python interpreter version for /usr/bin/python3. For `pants_version = "2.12.0"`, Pants requires Python 3.7, 3.8, or 3.9 to run

I do have Python 3.9.9 installed via asdf and activated for the sub-directory in question.

$ python --version 
Python 3.9.9

Moreover, my configuration already have Python 3.x installed as well by default. So even if I disable the asdf version I do have it in the system:

$ python --version
Python 3.10.5

Is there a way to just overcome this issue? I still don't understand why the pants script is unable to discover the Python interpreter. I do really prefer to use the local version that asdf "activates" because any time the system updates it will probably update the version to one that would be incompatible at some point.


Solution

  • There is an option to overcome this issue in pants.toml:

    [python-bootstrap]
    search_path = ["<ASDF_LOCAL>", "<PATH>"]
    

    This basically means Pants will first the ASDF interpreter with the version in <BUILD_ROOT>/.tool-versions and then what's in PATH.

    More information on this can be found here.

    Regardless, the setup process is all too titchy still and the system version must be set as well.

    I filed an issue in the Pants repository and that's where I got the help from. I'm just documenting what's there here.