rich-kite-32423
11/25/2022, 7:32 PMNo valid Python interpreter found. For `pants_version = "2.16.0.dev0"`, Pants requires Python 3.7, 3.8, or 3.9 to run. Please check that a valid interpreter is installed and on your $PATH.
From the docs, it appears that Pants will support builds with more recent versions of Python, but Pants itself cannot run with a version of Python newer than 3.9. So I install 3.9 following these instructions: https://www.debugpoint.com/install-python-3-11-ubuntu/ (substituting 3.9 instead of 3.11).
I make 3.9 the default following those instructions:
bruce@groot:/mnt/c/git/semaphore-demo-python-pants$ sudo update-alternatives --config python3
There are 2 choices for the alternative python3 (providing /usr/bin/python3).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/python3.10 2 auto mode
1 /usr/bin/python3.10 2 manual mode
* 2 /usr/bin/python3.9 1 manual mode
But when I try to run Pants I get:
bruce@groot:/mnt/c/git/semaphore-demo-python-pants$ pants test ::
Traceback (most recent call last):
File "/usr/lib/command-not-found", line 28, in <module>
from CommandNotFound import CommandNotFound
File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 19, in <module>
from CommandNotFound.db.db import SqliteDatabase
File "/usr/lib/python3/dist-packages/CommandNotFound/db/db.py", line 5, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
I try running the extra install command from here https://www.pantsbuild.org/docs/prerequisites#microsoft-windows:
bruce@groot:/mnt/c/git/semaphore-demo-python-pants$ sudo apt install unzip python3-dev python3-distutils python3-venv gcc
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
gcc is already the newest version (4:11.2.0-1ubuntu1).
python3-dev is already the newest version (3.10.6-1~22.04).
python3-distutils is already the newest version (3.10.6-1~22.04).
unzip is already the newest version (6.0-26ubuntu3.1).
python3-venv is already the newest version (3.10.6-1~22.04).
0 upgraded, 0 newly installed, 0 to remove and 20 not upgraded.
It seems like I missed a step or two somewhere...enough-analyst-54434
11/25/2022, 7:54 PMbruce@groot:/mnt/c/git/semaphore-demo-python-pants$ pants test ::
Traceback (most recent call last):
File "/usr/lib/command-not-found", line 28, in <module>
from CommandNotFound import CommandNotFound
File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 19, in <module>
from CommandNotFound.db.db import SqliteDatabase
File "/usr/lib/python3/dist-packages/CommandNotFound/db/db.py", line 5, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
Looks to me like setting the default 3.9 using alternatives borked your system maybe and has ~nothing to do with Pants - a guess.
I'd undo the alternatives bit. Pants just needs a Python 3.{7,8,9} to be visible on the PATH; that's all - it'll find it.enough-analyst-54434
11/25/2022, 7:54 PMenough-analyst-54434
11/25/2022, 7:56 PMenough-analyst-54434
11/25/2022, 7:59 PMpython3-distutils
and `python3-venv`though in your steps above, which is good. That should get you a full real Python install.enough-analyst-54434
11/25/2022, 8:51 PM