opencv / opencv

Open Source Computer Vision Library
https://opencv.org
Apache License 2.0
78.98k stars 55.8k forks source link

Python3 disabled via CMake even when explicitly turned on #8425

Closed Erotemic closed 7 years ago

Erotemic commented 7 years ago
System information (version)

OpenCV => 3.2.0 on commit c1007c7276e889f5f284702515a60b6799df9cd7 Operating System / Platform => Linux Ubuntu 16.04 64 bit

Detailed description

I'm trying to build opencv with python3, and I was having a hard time. Opencv found python3, but when I ran cmake, it always reported Python (for build) as nothing. Here is an example of how I ran cmake.

cmake -G "Unix Makefiles"     
-D WITH_OPENMP=ON    
 -D CMAKE_BUILD_TYPE=RELEASE     
-D BUILD_opencv_python2=Off   
 -D BUILD_opencv_python3=On     
-D PYTHON2_EXECUTABLE=""     
-D PYTHON2_INCLUDE_DIR=""     
-D PYTHON2_LIBRARY=""     
-D PYTHON2_PACKAGES_PATH=""     
-D OPENCV_FORCE_PYTHON_LIBS=On    
-D PYTHON3_PACKAGES_PATH=$PYTHON3_PACKAGES_PATH     
-D CMAKE_INSTALL_PREFIX=$LOCAL_PREFIX     
-D OPENCV_EXTRA_MODULES_PATH=$REPO_DIR/opencv_contrib/modules     
-D WITH_CUDA=Off     
$REPO_DIR

I would get output like this

-- 
--   Python 2:
--     Interpreter:                 (ver 2.7.12)
-- 
--   Python 3:
--     Interpreter:                 /home/joncrall/venv3_7/bin/python3 (ver 3.7)
--     Libraries:                   /home/joncrall/venv3_7/lib/libpython3.7m.so (ver 3.7.0a0)
--     numpy:                       /home/joncrall/venv3_7/lib/python3.7/site-packages/numpy/core/include (ver 1.12.1)
--     packages path:               /home/joncrall/venv3_7/lib/python3.7/site-packages
-- 
--   Python (for build):            

I was eventually able to trace the problem back to cmake/OpenCVDetectPython.cmake and found the issue in the following lines:

if(PYTHON_DEFAULT_EXECUTABLE)
    set(PYTHON_DEFAULT_AVAILABLE "TRUE")
elseif(PYTHON2INTERP_FOUND) # Use Python 2 as default Python interpreter
    set(PYTHON_DEFAULT_AVAILABLE "TRUE")
    set(PYTHON_DEFAULT_EXECUTABLE "${PYTHON2_EXECUTABLE}")
elseif(PYTHON3INTERP_FOUND) # Use Python 3 as fallback Python interpreter (if there is no Python 2)
    set(PYTHON_DEFAULT_AVAILABLE "TRUE")
    set(PYTHON_DEFAULT_EXECUTABLE "${PYTHON3_EXECUTABLE}")
endif()

for some reason PYTHON2INTERP_FOUND was True, so PYTHON_DEFAULT_EXECUTABLE was set to PYTHON2_EXECUTABLE, which was nothing, so the cv2.so library was never built.

It seems to me that main issue is the assumption that Python2 should be the default interpreter. I think the best way to fix this would be to introduce a configuration variable that explicitly tells opencv which python it should default to (or maybe the find python script could respect the BUILD_opencv_python2 and BUILD_opencv_python3 flags).

alalek commented 7 years ago

Currently there is no way to disable Python2 detection via passing of empty values (they are just partially ignored by find_package(PythonInterp) statement).

introduce a configuration variable that explicitly tells opencv which python it should default

cmake -DPYTHON_DEFAULT_EXECUTABLE=/usr/bin/python3 ... should work fine.

Python is used in many places (not for Python bindings only), so using of BUILD_opencv_python2/BUILD_opencv_python3 doesn't look reasonable.

Probably there is bad naming, but PYTHON_DEFAULT_EXECUTABLE defines executable, which will be used to run scripts during build. Changing of this variable should not have any effect on OpenCV bindings for Python 2/3.

Erotemic commented 7 years ago

cmake -DPYTHON_DEFAULT_EXECUTABLE=/usr/bin/python3 ... should work fine.

That's what I ended up settling on. Maybe PYTHON_DEFAULT_EXECUTABLE could be exposed in the cmake variables so this problem is solvable from cmake-gui?

wahyubram82 commented 5 years ago

I have the similar problem, couple days ago, I success install opencv in termux by following this instruction.

but few hours ago, an accidentially i install opencv module from termux because run script from here. It caused conflict so I cannot run import cv2 (error). so i uninstall the opencv and try to rebuild and reinstall again like the previous method.

and it's fail...

the cmake option i use:

LDFLAGS=" -llog -lpython3" cmake -D CMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local -D INSTALL_C_EXAMPLES=OFF -DINSTALL_PYTHON_EXAMPLES=OFF -D BUILD_EXAMPLES=OFF -DPYTHON_DEFAULT_EXECUTABLE=/data/data/com.termux/files/usr/bin/python3 -DPYTHON3_EXECUTABLE=/data/data/com.termux/files/usr/bin/python3 -DPYTHON3_INCLUDE_DIR=/data/data/com.termux/files/usr/include/python3.7m -DPYTHON3_INCLUDE_DIR2=/data/data/com.termux/files/usr/include/python3.7m -DPYTHON3_LIBRARY=/data/data/com.termux/files/usr/lib/libpython3.7m.so -DPYTHON3_NUMPY_INCLUDE_DIRS=/data/data/com.termux/files/usr/lib/python3.7/site-packages/numpy-1.17.1-py3.7-linux-aarch64.egg/numpy/core/include -DPYTHON3_PACKAGES_PATH=/data/data/com.termux/files/usr/lib/python3.7/site-packages DBUILD_opencv_python2=OFF -DANDROID_EXAMPLES_WITH_LIBS=OFF -DBUILD_ANDROID_EXAMPLES=OFF -DWITH_ANDROID_MEDIANDK=OFF -DOPENCV_GENERATE_PKGCONFIG=ON -DENABLE_SOLUTION_FOLDERS=ON -DBUILD_ANDROID_PROJECTS=OFF -DBUILD_ANDROID_SERVICE=OFF -DBUILD_JAVA=OFF -DOPENCV_EXTRA_MODULES_PATH=/data/data/com.termux/files/home/src/opencv_contrib/modules -DOPENCV_ENABLE_NONFREE:BOOL=ON -DWITH_QT=OFF -DWITH_GTK=OFF -D WITH_TEST=OFF -D BUILD_TESTS=OFF -D BUILD_EXAMPLES=OFF ..

but the result of cmake generation show like this:

--   OpenCV modules:
--     To be built:
aruco bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dpm face features2d flann freetype fuzzy hdf hfs highgui img_hash imgcodecs imgproc line_descriptor ml objdetect optflow phase_unwrapping photo plot quality reg rgbd saliency sfm shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
--     Disabled:  world
--     Disabled by dependency:      -
--     Unavailable:
cnn_3dobj cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv gapi java js matlab ovis python2 python3 viz

this result means I cannot binding it to python3

the other result:

--   Other third-party libraries:                                                              
--     Eigen:                       YES (ver 3.3.7)
--     Custom HAL:          YES (carotene (ver 0.0.1))                                 
--     Protobuf:                 build (3.5.1)  
--
--   Python 3:
--     Interpreter:  /data/data/com.termux/files/usr/bin/python3 (ver 3.7.4)    
--     Libraries:     NO
--     numpy:         /data/data/com.termux/files/usr/lib/python3.7/site-packages/numpy-1.17.1-py3.7-linux-aarch64.egg/numpy/core/include (ver )
--     install path:                -                                                          
--
--   Python (for build):            /data/data/com.termux/files/usr/bin/python3                
--                                                                     
--   Install to:                    /usr/local                                                 
-- -----------------------------------------------------------------

can somebody help me? remember...I already success installed it before, now I'm difficult to bind it to python3.

xjsxujingsong commented 4 years ago

@wahyubram82 did you solve this problem? I met the same problem that -- Unavailable: python3 Python 3: Interpreter: C:/Users/xjsxu/Anaconda3/python3.exe (ver 3.7.3) Libraries: NO numpy: C:/Users/xjsxu/Anaconda3/lib/site-packages/numpy/core/include (ver 1.16.2) install path: -

Python (for build): C:/Users/xjsxu/Anaconda3/python3.exe

wahyubram82 commented 4 years ago

@wahyubram82 did you solve this problem? I met the same problem that -- Unavailable: python3 Python 3: Interpreter: C:/Users/xjsxu/Anaconda3/python3.exe (ver 3.7.3) Libraries: NO numpy: C:/Users/xjsxu/Anaconda3/lib/site-packages/numpy/core/include (ver 1.16.2) install path: -

Python (for build): C:/Users/xjsxu/Anaconda3/python3.exe

yes, I already do it...the latest version more easy to binding with python3, and off course because python2 already deprected now.

from data that you share, I think, you not build it, but try to install it from pypy... if you try to install from pypi, I think, you must wait someone build it for us... but if you think this is an urgent, so build it from source and this the 'extra' module

how to install just googling: build opencv from soure.

just tips to build:

make sure you install: cmake and cmake-curses-gui.

after run command: 'cmake ..' with build option off course (use -D the option you choose). you can see some result from that reported by cmake...

if you think want to change it and don't know the option order (the -D with command option), so you run: ccmake . you will see all the options and more easy to handle, set as you want.

when you set an option to activate some capabilities, make sure you already install all the development dependencies module. e.g: with libpng-dev, will make opencv recognize that you already that feature, but if you just install libpng, opencv will not detect it. so will error if you run the build process (run make). so if there is error, 90% caused by the dependencies problem. I often solve it by install the new module. just read the reason, detect the dependencies that cause error, try to make sure you already install the dependencies correctly.

if python3 not detected:

like any other problem: apt install python3-dev (if exists in termux), if not, so you must build the python3 from the source.

why I give long advise, because I know it's just a beginning...lol...

the option when error: 1.install the dependencies that needed, or

  1. uncheck the features.

but if you sure the dependencies already installed, that's means, the problem came from the Makefile or Cmakelist.txt configuration. read the error and try to get the answer from the community of cmake or unix. because in my experience, the opencv team, many times cannot explaining it and only told you to remove the features that you want exists

xjsxujingsong commented 4 years ago

@wahyubram82 Thanks for your advice. Actually, the log I post here is the one I build OpenCV from source code using CMAKE GUI in windows. Actually, I have successfully built OpenCV with cuda, cudnn, contrib, and other additional modules. Following above suggestion, I have manually disabled Python2. The trouble here is I cannot generate python support.

In my Windows machine, I use Anaconda. And you can see CMake has already found anaconda, my question is why CMake still cannot find Pyhon 3 module. Originally, my machine only has the command "python.exe", I manually copy and paste this python.exe to python3.exe. However, there is no difference.

I tried OpenCV 4.3.0 and 4.2.0

wahyubram82 commented 4 years ago

@jsxyhelu :

@wahyubram82 Thanks for your advice. Actually, the log I post here is the one I build OpenCV from source code using CMAKE GUI in windows. Actually, I have successfully built OpenCV with cuda, cudnn, contrib, and other additional modules. Following above suggestion, I have manually disabled Python2. The trouble here is I cannot generate python support.

In my Windows machine, I use Anaconda. And you can see CMake has already found anaconda, my question is why CMake still cannot find Pyhon 3 module. Originally, my machine only has the command "python.exe", I manually copy and paste this python.exe to python3.exe. However, there is no difference.

I tried OpenCV 4.3.0 and 4.2.0

No, problem...I just remember my hard time when in your position...lol

ok,

base on code in CMakelist.txt:

if(BUILD_opencv_python3)
  status("")
  status("  Python 3:")
  status("    Interpreter:"     PYTHON3INTERP_FOUND  THEN "${PYTHON3_EXECUTABLE} (ver ${PYTHON3_VERSION_STRING})"       ELSE NO)
  if(PYTHON3LIBS_VERSION_STRING)
    status("    Libraries:"   HAVE_opencv_python3  THEN  "${PYTHON3_LIBRARIES} (ver ${PYTHON3LIBS_VERSION_STRING})"   ELSE NO)
  else()
    status("    Libraries:"   HAVE_opencv_python3  THEN  "${PYTHON3_LIBRARIES}"                                      ELSE NO)
  endif()
  status("    numpy:"         PYTHON3_NUMPY_INCLUDE_DIRS THEN "${PYTHON3_NUMPY_INCLUDE_DIRS} (ver ${PYTHON3_NUMPY_VERSION})" ELSE "NO (Python3 wrappers can not be generated)")
  status("    install path:"  HAVE_opencv_python3  THEN "${__INSTALL_PATH_PYTHON3}"                            ELSE "-")
endif()

only in that section that have BUILD_opencv_python3, means the code expecting another triger from another process.

and the triger is the result of searching the python3 when running the file *.cmake in opencv\cmake folder. ok, we check that folder, and....aha... you will find file OpenCVDetectPython.cmake on that folder.

btw, sorry to not giving picture or something else, I use github to see the file structure, and I already change to linux mint, because all i need from windows only the office...lol...

ok, let me see it, hope it that i can understand the script.

ah..., here:

if(WIN32 AND NOT ${executable} AND OPENCV_PYTHON_PREFER_WIN32_REGISTRY)  # deprecated
    # search for executable with the same bitness as resulting binaries
    # standard FindPythonInterp always prefers executable from system path
    # this is really important because we are using the interpreter for numpy search and for choosing the install location
    foreach(_CURRENT_VERSION ${Python_ADDITIONAL_VERSIONS} "${preferred_version}" "${min_version}")
      find_host_program(PYTHON_EXECUTABLE
        NAMES python${_CURRENT_VERSION} python
        PATHS
          [HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Python\\\\PythonCore\\\\${_CURRENT_VERSION}\\\\InstallPath]
          [HKEY_CURRENT_USER\\\\SOFTWARE\\\\Python\\\\PythonCore\\\\${_CURRENT_VERSION}\\\\InstallPath]
        NO_SYSTEM_ENVIRONMENT_PATH
      )
    endforeach()
  endif()

you see something familiar? the script told to cek the Registry, the rgistry that contain environtment path. first point, big posibilities, it because you not set PYTHONPATH to the windows environtment system settings. you know what i mean is it? it's a menu to input a folder to make you can call any apps from any folder.

then, i'm interisting with this script:

        if(_python_version_major STREQUAL "2")
          set(__PYTHON_PREFIX Python2)
        else()
          set(__PYTHON_PREFIX Python3)
        endif()

the author looks like more comfortable using python 2, so it set to first option, with a condition if the python 2 are the major "STREQUAL". believe me, until now I don't know how to make which version python is more major from the other, and "STREQUAL" is a variabel that should be set on another file.

if me i change it, only typing: set(__PYTHON_PREFIX Python3)

because I only use python3, if need a module from python2, i re-write the code to make it run in python 3. not so hard as many people perceive.

make sure you backup first, or if it failed, download again that file from github. carefull with the number of space. the code structure base on the number of space before the script.

the structure of script base on the position from the left margin, yup like using it in the office, using the space to make different between the main and sub or the sub script with more-more sub script. I will visualize it by symbol: -

main code
--sub main code
----more sub code        --> position `if` code
------more more sub code     --> position `set` code
----more sub code, etc

so the position of the code set(__PYTHON_PREFIX Python3) should replace the position of if(_python_version_major STREQUAL "2"), understand what i means?

means: delete the script above from if(_python_version_major STREQUAL "2") until endif() replace it with: set(__PYTHON_PREFIX Python3), and the position should be exactly replace the if(_python_version_major STREQUAL "2") position.

to make you more comfortable to change, the meaning of the code is:

  1. if version of python that found is more 'important' or prefered, he means python2 (comment: this is one that i don't understand how to make it more prefered? all i know just call python2 or python3, lol...)
  2. if true like that, so set python2 as the options.
  3. else, means if not true:
  4. set python3 as the options.

ok, i know how the author mark it as 'more preffered', the author have perception that:

if there is two version of python, which one instaling numpy, thats it's the main python.

the problem is...

  1. how about both version installed numpy? so..., base on the script... it will choose python 2 more 'important' not python 3. that's the reason.
  2. and how about if you not installed numpy on both version, or not set the environtment, or not do one of it, may be not giving any result. so you cannot binding it to python.

i think because of it. but to make it more sure, must check the main srcipts files who connected the CmakeList and the 'cmakepython' for make it sure, must check it directly, but unfortunately i'm in linux now. not an ideal condition to cek in windows, but FYI not so hard the condition in linux.

btw, github is open source, many people can help write that code, don't blame the main author of OpenCV.

So the conclution is:

because of the Cmake script of OpenCV cannot found your python existent or prefer python 2 than python3.

my tips to solve that: Options 1:

  1. delete all file that produce by Cmake in build folder, if not major change not need to delete, but i think this is a major change.
  2. add new environtment named PYTHONPATH to your environtment system and put all folder that opencv need (lib, exe file, python.h, site-packages, script folder ,etc), dont forget to add new Path with insert %PYTHONPATH% to the Path.
  3. close cmake-gui, open it again, to refresh and reading the new environtment, then try to re-configure, and see the result as expected or not.

if not working: Option 2:

  1. delete old files that produce by CMake
  2. My perception now, the Windows Environtment System already has PYTHONPATH, test it with type: Path or path, lol..i forget which one the correct one... If no respon, close command prompt, open the new one, in purpose to make CMD / command prompt read the new environtment.
  3. run from command prompt:

build_folder> folder_cmake\cmake.exe -D BUILD_opencv_python3=ON -DPYTHON3_EXECUTABLE=python_folder\python3.exe -DPYTHON3_LIBRARY=folder\python_library_file.lib -DPYTHON3_INCLUDE_DIR=python_include_folder -DPYTHON3_PACKAGES_PATH=python_folder\site-packages_dir -DPYTHON3_NUMPY_INCLUDE_DIRS=python_folder\site-packages\numpy\core\include\ ..

don't forget end it by .., it force CMAKE to re-thinking about the result condition.

the last option, Option 3: change the script like i explaining above...

Good Luck...,

NB: I'm sorry for the typo...hard to type in my PC keyboard. not comfortable as in Laptop. old keyboard. Already re-read three times, hope no more typo.

xjsxujingsong commented 4 years ago

@wahyubram82 Thank you very much!!!

I followed your solution one by one

  1. The first one doesnot work for me when I use CMake-GUI.
  2. This one work perfect. After this option works, I tried to add entry of python related using CMake-GUI, however, it still cannot work. So finally I have to go to use command line version. I did not try option 3.

To help anyone that have the same problem. I copied my cmake options here with cuda.

"C:/Program Files/CMake/bin/cmake.exe" -G "Visual Studio 15 2017 Win64" ^ -DBUILD_opencv_python3=ON ^ -DPYTHON3_EXECUTABLE=C:/Users/xjsxu/Anaconda3/python3.exe ^ -DPYTHON3_LIBRARY=C:/Users/xjsxu/Anaconda3/libs/python37.lib ^ -DPYTHON3_INCLUDE_DIR=C:/Users/xjsxu/Anaconda3/include ^ -DPYTHON3_PACKAGES_PATH=C:/Users/xjsxu/Anaconda3/Lib/site-packages ^ -DPYTHON3_NUMPY_INCLUDE_DIRS=C:/Users/xjsxu/Anaconda3/Lib/site-packages/numpy/core/include ^ -DOPENCV_SKIP_PYTHON_LOADER=ON ^ -DINSTALL_TESTS=OFF -DINSTALL_C_EXAMPLES=OFF -DBUILD_EXAMPLES=OFF ^ -DBUILD_opencv_world=ON ^ -DWITH_CUDA=ON -DCUDA_TOOLKIT_ROOT_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.0" -DCUDA_FAST_MATH=ON -DWITH_CUBLAS=ON -DCUDA_ARCH_BIN=5.3,6.0,6.1,7.0,7.5 -DCUDA_ARCH_PTX=7.5 -DWITH_NVCUVID=ON ^ -DWITH_OPENGL=ON ^ -DWITH_MFX=ON ^ -DOPENCV_ENABLE_NONFREE=ON -DBUILD_opencv_rgbd=OFF ^ -DWITH_MKL=ON ^ -DOPENCV_EXTRA_MODULES_PATH=D:/study/opencv/opencv-4.3.0/opencv_contrib-4.3.0/modules ^ ../sources

wahyubram82 commented 4 years ago

nice can help you bro..., yeah, the third options is not too comfortable for many people.

just give a remain, if someone do not know what options should they write, just open the cmake-gui, open text editor, and copy every options that they want, reline it with add -D in front of (before) the option...with space like: -D option1=ON or without space like: -Doption1=ON, it doesn't matters...

the folder format in windows is C:\folder\folder\file, several time, accidentially, i type folder/folder/file. lol...linux user behaviour..., lucky the cmake is app from linux so it not error when you apply linux format...lol...

starboy-07 commented 4 years ago
System information (version)

OpenCV => 3.2.0 on commit c1007c7 Operating System / Platform => Linux Ubuntu 16.04 64 bit

Detailed description

I'm trying to build opencv with python3, and I was having a hard time. Opencv found python3, but when I ran cmake, it always reported Python (for build) as nothing. Here is an example of how I ran cmake.

cmake -G "Unix Makefiles"     
-D WITH_OPENMP=ON    
 -D CMAKE_BUILD_TYPE=RELEASE     
-D BUILD_opencv_python2=Off   
 -D BUILD_opencv_python3=On     
-D PYTHON2_EXECUTABLE=""     
-D PYTHON2_INCLUDE_DIR=""     
-D PYTHON2_LIBRARY=""     
-D PYTHON2_PACKAGES_PATH=""     
-D OPENCV_FORCE_PYTHON_LIBS=On    
-D PYTHON3_PACKAGES_PATH=$PYTHON3_PACKAGES_PATH     
-D CMAKE_INSTALL_PREFIX=$LOCAL_PREFIX     
-D OPENCV_EXTRA_MODULES_PATH=$REPO_DIR/opencv_contrib/modules     
-D WITH_CUDA=Off     
$REPO_DIR

I would get output like this

-- 
--   Python 2:
--     Interpreter:                 (ver 2.7.12)
-- 
--   Python 3:
--     Interpreter:                 /home/joncrall/venv3_7/bin/python3 (ver 3.7)
--     Libraries:                   /home/joncrall/venv3_7/lib/libpython3.7m.so (ver 3.7.0a0)
--     numpy:                       /home/joncrall/venv3_7/lib/python3.7/site-packages/numpy/core/include (ver 1.12.1)
--     packages path:               /home/joncrall/venv3_7/lib/python3.7/site-packages
-- 
--   Python (for build):            

I was eventually able to trace the problem back to cmake/OpenCVDetectPython.cmake and found the issue in the following lines:

if(PYTHON_DEFAULT_EXECUTABLE)
    set(PYTHON_DEFAULT_AVAILABLE "TRUE")
elseif(PYTHON2INTERP_FOUND) # Use Python 2 as default Python interpreter
    set(PYTHON_DEFAULT_AVAILABLE "TRUE")
    set(PYTHON_DEFAULT_EXECUTABLE "${PYTHON2_EXECUTABLE}")
elseif(PYTHON3INTERP_FOUND) # Use Python 3 as fallback Python interpreter (if there is no Python 2)
    set(PYTHON_DEFAULT_AVAILABLE "TRUE")
    set(PYTHON_DEFAULT_EXECUTABLE "${PYTHON3_EXECUTABLE}")
endif()

for some reason PYTHON2INTERP_FOUND was True, so PYTHON_DEFAULT_EXECUTABLE was set to PYTHON2_EXECUTABLE, which was nothing, so the cv2.so library was never built.

It seems to me that main issue is the assumption that Python2 should be the default interpreter. I think the best way to fix this would be to introduce a configuration variable that explicitly tells opencv which python it should default to (or maybe the find python script could respect the BUILD_opencv_python2 and BUILD_opencv_python3 flags).

I'm not even getting Python3 under Interpreter tab, and numpy under Libraries tab. Please help Screenshot from 2020-06-16 14-35-55

edmund3333 commented 4 years ago

Win10 OpenCV 4.4 with cmake-gui for WinPython 3.7 venv (Solution for missing python3 binding)

I followed the instructions at https://jamesbowley.co.uk/accelerate-opencv-4-3-0-build-with-cuda-and-python-bindings/ and found out that python3 was unavailable for opencv

image

beside it was available for build:

image

At the top oft he cmake output was the info from the missing PythonLibs:

image

This Information only showed up after the first start of cmake or after File->“Delte Cache“. After hitting „Configure“ the python3 binding was unavailable (pic above) also after adding the path to „python37.lib“ to „PYTHON3_LIBRARY“. The virtual environments do not contain the „python37.lib“ so i used the path to the python base installation but with no success.

Solution: Add the folder to „python37.lib“ to the path variable and select File->“Delte Cache“ and restart cmake so that „cmake/OpenCVDetectPython.cmake“ can find it.

image

image (i changed the "PYTHON3_INCLUDE_DIR" to my venv afterwards)

image

now python3 shows up in "to be built" is working: image

jahaniam commented 4 years ago

Thanks @edmund3333 .

I use Anaconda for python3 and I don't have any python2. Your solution solved my problem.

export PATH=$PATH:$USER/anaconda3/lib

then cmake-gui or cmake in the same terminal.

gemfield commented 4 years ago
-- Module opencv_python3 disabled by whitelist
--     Disabled by dependency:      calib3d dnn features2d flann gapi highgui java_bindings_generator ml objdetect photo python3 python_bindings_generator python_tests stitching ts videoio

opencv_python3 also has other dependencies.