Open braindevices opened 3 years ago
I have a similar issue when building OpenCV 4.6.0 on macOS 12.5.1 with Apple Silicon (arm64).
OpenCVDetectPython.cmake
fails to detect correctly Python 3 from Brew:
...
-- Detected processor: arm64
-- Found PythonInterp: /usr/bin/python2.7 (found suitable version "2.7.18", minimum required is "2.7")
-- Found PythonLibs: /usr/lib/libpython2.7.dylib (found suitable exact version "2.7.18")
-- Found PythonInterp: /opt/homebrew/bin/python3 (found suitable version "3.9.13", minimum required is "3.2")
-- Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS) (Required is exact version "3.9.13")
...
The CMake "call stack" is
I provided a patch to the CMake project to fix CMakeFindFrameworks.cmake
:
https://gitlab.kitware.com/cmake/cmake/-/merge_requests/7618
The OpenCV project should move away from using FindPythonLibs.cmake
and FindPythonInterp.cmake
(both are deprecated since CMake 3.12)
The OpenCV project should move away from using FindPythonLibs.cmake and FindPythonInterp.cmake (both are deprecated since CMake 3.12)
You are referring to https://cmake.org/cmake/help/latest/policy/CMP0148.html - should we open another issue for this, or should the issue be dedicated to moving to the new modules?
current output of cmake
CMake Warning (dev) at cmake/OpenCVUtils.cmake:144 (find_package):
Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules
are removed. Run "cmake --help-policy CMP0148" for policy details. Use
the cmake_policy command to set the policy and suppress this warning.
Call Stack (most recent call first):
cmake/OpenCVDetectPython.cmake:64 (find_host_package)
cmake/OpenCVDetectPython.cmake:286 (find_python)
CMakeLists.txt:660 (include)
This warning is for project developers. Use -Wno-dev to suppress it.
Found PythonInterp: C:/Program Files/Python311/python.exe (found suitable version "3.11.4", minimum required is "3.2")
CMake Warning (dev) at cmake/OpenCVDetectPython.cmake:140 (find_package):
Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules
are removed. Run "cmake --help-policy CMP0148" for policy details. Use
the cmake_policy command to set the policy and suppress this warning.
Call Stack (most recent call first):
cmake/OpenCVDetectPython.cmake:286 (find_python)
CMakeLists.txt:660 (include)
This warning is for project developers. Use -Wno-dev to suppress it.
Found PythonLibs: C:/Program Files/Python311/libs/python311.lib (found suitable exact version "3.11.4")
This presents a strong case to bump the minimum required CMake version to 3.12 in OpenCV5. Anyone compiling on a new Windows or MacOS machine may hit this now that those OS's will come with CMake >=3.27.
Has anyone looked into if FindPython3 will work?
System information (version)
Detailed description
After activate the venv and run cmake config:
This problem is caused by the deprecated
FindPythonLibs
, it is too old and has many unfixed bugs. Please useFindPython
which actually usepython -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())"
to find the include dir andpython -c "import distutils.sysconfig as sysconfig; print(sysconfig.get_config_var('LIBDIR'))"
to find the libs.from cmake document:
since in the
OpenCVDetectPython.cmake
it already conditioned with cmake version 3.12+, I think we should use FindPython there when cmake version >= 3.12 for much better python supportSteps to reproduce
Issue submission checklist