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

**URL:** <https://forum.opencv.org/t/building-opencv-python-from-source-on-windows-doesnt-work-for-python/7729>\
**Category:** Python\
**Tags:** build\
**Created:** [February 26, 2022, 6:12pm UTC](https://forum.opencv.org/t/building-opencv-python-from-source-on-windows-doesnt-work-for-python/7729 "2022-02-26T18:12:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![azad.wolf](https://avatars.discourse-cdn.com/v4/letter/a/f6c823/32.png) [@azad.wolf](https://forum.opencv.org/u/azad.wolf)\
**Post date:** [February 26, 2022, 6:12pm UTC](https://forum.opencv.org/t/building-opencv-python-from-source-on-windows-doesnt-work-for-python/7729/1 "2022-02-26T18:12:18Z")

</div>

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](https://github.com/opencv/opencv-python)). The wheel was created successfully and it works in contrast to the visual studio compilation.

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [February 26, 2022, 6:28pm UTC](https://forum.opencv.org/t/building-opencv-python-from-source-on-windows-doesnt-work-for-python/7729/2 "2022-02-26T18:28:14Z")

</div>

can you show the cmake output, please ?

---

<div class="post-metadata">

**Author:** ![azad.wolf](https://avatars.discourse-cdn.com/v4/letter/a/f6c823/32.png) [@azad.wolf](https://forum.opencv.org/u/azad.wolf)\
**Post date:** [February 26, 2022, 6:53pm UTC](https://forum.opencv.org/t/building-opencv-python-from-source-on-windows-doesnt-work-for-python/7729/3 "2022-02-26T18:53:20Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [February 26, 2022, 6:55pm UTC](https://forum.opencv.org/t/building-opencv-python-from-source-on-windows-doesnt-work-for-python/7729/4 "2022-02-26T18:55:23Z")

</div>

no, the console output

---

<div class="post-metadata">

**Author:** ![azad.wolf](https://avatars.discourse-cdn.com/v4/letter/a/f6c823/32.png) [@azad.wolf](https://forum.opencv.org/u/azad.wolf)\
**Post date:** [February 26, 2022, 6:57pm UTC](https://forum.opencv.org/t/building-opencv-python-from-source-on-windows-doesnt-work-for-python/7729/5 "2022-02-26T18:57:26Z")

</div>

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