Installing lammps python module: cmake fails to find python3.8

building lammps with cmake in order to use it as a python package, the procedure finds python 2.7 instead of python 3.8

when I ckeck the python version with the python command I get
Python 3.8.10 (default, Jun 22 2022, 20:18:18)
I have both python 3.8 and python 2.7 on my system in the /usr/bin folder (Ubuntu 20.04.4 running on wsl2 on windows 11)
I download lammps-23Jun2022 and then follow the procedure starting from the lammps parent folder
mkdir build
cd build
cmake -C …/cmake/presets/basic.cmake -D BUILD_SHARED_LIBS=on /

the output pertaining the python version is
– Found Python: /usr/bin/python2.7 (found version “2.7.18”) found components: Interpreter Development
and following the whole procedure I get a lammps python module for python 2.7.
without python 2.x installed, the cmake command above doesn’t even find python
Thank you in advance

You should be able to enforce using a particular Python interpreter and version through adding -DPython_EXECUTABLE=/path/to/python

Please make certain that you have the Python interpreter and the matching development package installed.

Thanks, it worked. However there’s still an unexpected behaviour when installing with
sudo cmake --install . --prefix /usr
it installs the python module in /root/.local/lib instead of /usr/lib
(output is lines like byte-compiling /root/.local/lib/python3.10/site-packages/lammps/ to constants.cpython-310.pyc)

You have to set the destination folder when you configure with CMake through - DCMAKE_INSTALL_PREFIX
Please see the LAMMPS manual about it.