Hello everyone! I cannot get CMake to find my Python libraries; I’m getting this error.
I’m on MSYS2 on Windows 10 (which I think might be part of the problem).
Hello everyone! I cannot get CMake to find my Python libraries; I’m getting this error.
I’m on MSYS2 on Windows 10 (which I think might be part of the problem).
Indeed, MSYS2
environment should be used coherently (i.e. all tools must be from the same environment).
First question: what do you want to use: MSYS2
or MINGW64
? (i.e. what is the value of environment variable MSYSTEM
?).
If it is MSYS2
, you must use the cmake
tool provided by this environment (other cmake
tools will not work as expected) and also use the python from this environment (typical packages msys/cmake
, msys/python
and msys/python-devel
).
If it is MINGW64
, you can use Windows
cmake
or MNGW64
cmake
(package mingw64/mingw-w64-x86_64-cmake
) but you must have consistency between python and the compiler: use Microsoft compiler with standard python (from python.org
) or use GNU
gcc
with python provided by MINGW64
environment (package mingw64/mingw-w64-x86_64-python
).
Hi Marc!
I’m actually using CLANG64 - it looks like CMake can find the wrong Python interpreter if you have multiple ones installed (clang64/python3, msys/python3).
Even though the clang python was first in my path, CMake ignored the following options to continue to find the wrong Python:
PYTHON3_EXECUTABLE
PYTHON3_INCLUDE_DIR
PYTHON3_LIBRARY
PYTHON_EXECUTABLE
PYTHON_INCLUDE_DIR
PYTHON_LIBRARY
In the end, I uninstalled msys/python, forcing CMake to find the correct Python, and all was well. It was extremely frustrating.
I wonder if it is some mistake of mine, in the project I was building, or if it was an issue with CMake.
If you want to specify a Hint
variable, use the correct one!
If you request Python3
package, Python3_EXECUTABLE
can be specified. Case is important, PYTHON3
in uppercase is not correct. And the same of PYTHON
or Python
which are irrelevant in this case.
If you request Python
package, Python_EXECUTABLE
can be used, nothing else!
And specifying the executable is enough, all other artifacts are deduced from the interpreter itself.
And to finish, without a full snippet showing exactly what are the variables you have defined and how you call the find_package
, hard to say more…