openmopac/mopac

cmake error with newer python 3.11.2

flatstik opened this issue · 2 comments

-- Could NOT find Python3 (missing: Python3_NumPy_INCLUDE_DIRS NumPy) (found version "3.11.2")
CMake Error at CMakeLists.txt:261 (message):
Python3 and Numpy are required for MOPAC testing (testing can be disabled
with -DTESTS=OFF)

I encounter this problem frequently myself. It happens when there are multiple versions of Python installed on a system, and CMake arbitrarily picks one without actually checking which versions have NumPy installed. In principle, CMake should be smart enough to find a version of Python that supports NumPy if one is available, but it doesn't quite work out that way in practice.

The simplest workaround is to just install NumPy for whatever version of Python CMake has detected using pip. However, it isn't necessarily clear which version of Python it found without examining CMake variables. I will expand the error message to provide instructions on which version of Python is being used and how to pip-install NumPy to it. I will also look into ways to force CMake to use a specific version of Python, but I'm not sure if that is easy to do.

I made the error message more verbose when CMake fails to detect Python or NumPy. It will report the path of the Python interpreter that CMake has detected, and you can either install NumPy to that location with pip or increase the priority of a Python interpreter in a different location with NumPy installed (e.g. have it appear earlier in your PATH or activate an appropriate Conda environment).