Cannot open file 'python39_d.lib'

I try to build opencv 4.5.5 with python 3.9 on Visual Studio 2022 Community edition.
The configuration with CMake v3.22.1 is successfully.
And the build is almost fine. But I’ve got an error.

Error LNK1104 cannot open file ‘python39_d.lib’ opencv_python3

I do downloaded debug library for python during install python.
So python39_d.lib file exists on \libs.

Why did this error happen? How can I get rid of the error?

Without seeing more diagnostic information it is hard to ascertain the problem exactly. Off-hand, it seems like its probably one of a couple things:

(1) Are you certain \libs is in your library include path (Properties->Linker->General->Additional Library Directories)?

(2) Did you possibly do it for the wrong target (e.g. release instead of debug)?

(3) It sounds like you shouldn’t need to, but do you need to add “python39_d.lib” to Properties->Linker->Input->Additional Dependencies ?

don’t build as “debug”. then you won’t need python39_d.lib.

build as “release”.