Building OpenCV-Python from source on Windows doesn't work for Python

I have built the latest OpenCV4.5.5 from github repository on Windows using CMake and Visual Studio 2019. Then I have tried to deploy/install the OpenCV module for Python. I have anaconda working on the system and I can run opencv in an environment if I install the binaries through pip. But I want to build from source in order to use Cuda version of DNN which is not possible with the pre-built libraries.

I have created a new environment before building the OpenCV and have used the environment’s lib/site-packages path in the CMake as a python3 packages path. Then I have built the INSTALL project in the visual studio and have gotten an installed libraries folder with lib, bin and includes. However, I still do not have anything in anaconda environment and ’ import cv2 ’ doesn’t work in the newly created environment.

Why don’t visual studio generate python library as well?

In addition to the above I have also tried to create a pip wheel from source of opencv-python repo from github (https://github.com/opencv/opencv-python). The wheel was created successfully and it works in contrast to the visual studio compilation.

can you show the cmake output, please ?

Do you mean CMakeOutput.log? The text in the file is too large to fit in this reply and this forum doesn’t allow any attachments. Any other way to share it?

no, the console output

I used the CMake-Gui and this log file is actually what would be at the terminal.