cmake/OpenCVDetectPython.cmake:58 (find_host_package)

I encountered this problem while CMake compiling. Does anyone know what I should do? Could you please help me take a look.

cmake .. -DCMAKE_BUILD_TYPE=Release \
        -DCMAKE_INSTALL_PREFIX=/usr/local \
        -DBUILD_SHARED_LIBS=ON \
        -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.10.0/modules \
        -DOPENCV_ENABLE_NONFREE=ON \
        -DBUILD_TESTS=ON -DBUILD_PERF_TESTS=ON \
        -DOPENCV_GENERATE_PKGCONFIG=ON \
        -DWITH_GTK=ON \
        -DWITH_CUDA=ON -DENABLE_FAST_MATH=ON -DCUDA_FAST_MATH=ON -D WITH_CUBLAS=ON \
        -DCUDA_ARCH_BIN=8.6 \
        -DWITH_CUDNN=ON -DOPENCV_DNN_CUDA=ON \
        -DWITH_IPP=ON -DWITH_TBB=ON -DWITH_OPENMP=ON -DWITH_PTHREADS_PF=ON \
        -DOPENCV_PYTHON3_VERSION=ON \
        -DPYTHON3_EXECUTABLE=/usr/bin/python3 \
        -DPYTHON3_LIBRARY=$(python3 -c "import sysconfig; from os.path import join; print(join(sysconfig.get_config_var('LIBDIR'), sysconfig.get_config_var('LDLIBRARY')))") \
        -DPYTHON3_NUMPY_INCLUDE_DIRS=$(python3 -c "import numpy; print(numpy.get_include())") \
        -DPYTHON3_PACKAGES_PATH=$(python3 -c "import sysconfig; print(sysconfig.get_path('purelib'))") \
        -DWITH_OPENGL=ON
-- ocv_init_download: OpenCV source tree is not fetched as git repository. 3rdparty resources will be downloaded from github.com by default.
-- Detected processor: x86_64
CMake Error at cmake/OpenCVUtils.cmake:144 (find_package):
  find_package called with invalid argument "ON"
Call Stack (most recent call first):
  cmake/OpenCVDetectPython.cmake:58 (find_host_package)
  cmake/OpenCVDetectPython.cmake:286 (find_python)
  CMakeLists.txt:678 (include)


-- Python is not found: ON EXACT
-- Looking for ccache - not found

that’s step 0.001.
if you want to build from src, it needs to download it from github, but it could not.

it needs internet access while running cmake !

anyway, do yourself a favour, and dl the opencv repos before that using git clone

@berak Hello, I am the source code of 4.10.0 downloaded from “Release OpenCV 4.10.0 · opencv/opencv · GitHub”.
And I use CMake GUI as if it was no problem after compilation.
I don’t know what to do. Could you help me,?thank you
(My English is not very good. It is translated by Google. If there is any impolite place, please don’t mind.)

so, now to python…

what do you have installed, exactly ? (more than 1 py ?)
you’re using python scripts to locate it from cmake, please show the result of those (run them on plain cmdline)

(ps, i closed your other q. on same topic, no duplicates, please)

1 Like

Sorry,I will be careful not to submit duplicate topics again next time.
This followings is the path I ran using a python3 script.Please help me.

        -DOPENCV_PYTHON3_VERSION=ON \
        -DPYTHON3_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.11.so \
        -DPYTHON3_NUMPY_INCLUDE_DIRS=/usr/lib/python3/dist-packages/numpy/core/include \
        -DPYTHON3_PACKAGES_PATH=/usr/local/lib/python3.11/dist-packages \
1 Like