openmopac / mopac

Molecular Orbital PACkage
http://openmopac.net
GNU Lesser General Public License v3.0
111 stars 31 forks source link

cmake error with newer python 3.11.2 #162

Closed flatstik closed 11 months ago

flatstik commented 1 year ago

-- 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)

godotalgorithm commented 1 year ago

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.

godotalgorithm commented 11 months ago

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).