Ask Your Question
0

OpenCV build for Windows x64/Python3.7 from source. Where is the .pyd file?

asked 2020-01-18 08:16:20 -0600

g40 gravatar image

updated 2020-01-18 09:36:20 -0600

CMake is AFAICT correctly configured and producing the usual .DLL files in build/bin/Debug (as that is the configuration I'd like). The settings for Python3 have the correct directories and BUILD_XXX settings

CMake settings

The only relevant Python stuff I can find is in build/python_loader which has a setup.py file as I'd expect. Running this produces 'opencv\build\python_loader\dist\opencv-4.2.0-py3.7.egg' but no .pyd file. It is installing to the correct directory but the all important DLL file is missing.

So: How does the .pyd file get produced? Which stage of the build?

[Edit] To clarify: the CMake generated project files have all been loaded into VS and built by this stage. All of the OCV .DLL files are created as expectedlink text.

MTIA.

[running build_py
creating build\bdist.win-amd64\egg
creating build\bdist.win-amd64\egg\cv2
copying build\lib\cv2\config.py -> build\bdist.win-amd64\egg\cv2
copying build\lib\cv2\load_config_py2.py -> build\bdist.win-amd64\egg\cv2
copying build\lib\cv2\load_config_py3.py -> build\bdist.win-amd64\egg\cv2
copying build\lib\cv2\__init__.py -> build\bdist.win-amd64\egg\cv2
byte-compiling build\bdist.win-amd64\egg\cv2\config.py to config.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\cv2\load_config_py2.py to load_config_py2.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\cv2\load_config_py3.py to load_config_py3.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\cv2\__init__.py to __init__.cpython-37.pyc
creating build\bdist.win-amd64\egg\EGG-INFO
copying opencv.egg-info\PKG-INFO -> build\bdist.win-amd64\egg\EGG-INFO
copying opencv.egg-info\SOURCES.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying opencv.egg-info\dependency_links.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying opencv.egg-info\requires.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying opencv.egg-info\top_level.txt -> build\bdist.win-amd64\egg\EGG-INFO
zip_safe flag not set; analyzing archive contents...
cv2.__pycache__.__init__.cpython-37: module references __file__
creating 'dist\opencv-4.2.0-py3.7.egg' and adding 'build\bdist.win-amd64\egg' to it
removing 'build\bdist.win-amd64\egg' (and everything under it)
Processing opencv-4.2.0-py3.7.egg
removing 'r:\apps\python3\lib\site-packages\opencv-4.2.0-py3.7.egg' (and everything under it)
creating r:\apps\python3\lib\site-packages\opencv-4.2.0-py3.7.egg
Extracting opencv-4.2.0-py3.7.egg to r:\apps\python3\lib\site-packages
opencv 4.2.0 is already the active version in easy-install.pth

Installed r:\apps\python3\lib\site-packages\opencv-4.2.0-py3.7.egg
Processing dependencies for opencv==4.2.0
Searching for numpy==1.19.0.dev0+bf6859c
Best match: numpy 1.19.0.dev0+bf6859c
Processing numpy-1.19.0.dev0+bf6859c-py3.7-win-amd64.egg
numpy 1.19.0.dev0+bf6859c is already the active version in easy-install.pth
Installing f2py-script.py script to R:\apps\python3\Scripts
Installing f2py.exe script to R:\apps\python3\Scripts

Using r:\apps\python3\lib\site-packages\numpy-1.19.0.dev0+bf6859c-py3.7-win-amd64.egg
Finished processing dependencies for opencv==4.2.0](/upfiles/1579356898460004.jpg)
edit retag flag offensive close merge delete

Comments

in build\opencv\lib\python3\Release

LBerger gravatar imageLBerger ( 2020-01-18 08:23:18 -0600 )edit
1

"there is no DEBUG python lib" not exactly. python can be build in debug but to run opencv for python in debug it is necessary to build all import in debug. build numpy in debug configuation it's a problem

LBerger gravatar imageLBerger ( 2020-01-18 08:31:06 -0600 )edit
1

well, it's not part of a normal python distribution, right ?

berak gravatar imageberak ( 2020-01-18 08:33:23 -0600 )edit

No I have downloaded python source

LBerger gravatar imageLBerger ( 2020-01-18 08:55:17 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
0

answered 2020-01-18 08:27:02 -0600

berak gravatar image

updated 2020-01-18 08:32:15 -0600

  • cmake does not build anything. it only creates project files for the c++ compiler / ide. then you have to open the opencv.sln, and build the INSTALL project.
  • there is no DEBUG python lib, so it can't create a pyd in DEBUG, only in RELEASE mode.
  • if you're mainly interested in the python bindings, use cmake -DBUILD_SHARED_LIBS=OFF to get a self-contained pyd (no further opencv dlls nessecary)
  • building the INSTALL project, will copy the final pyd to your site-packages
edit flag offensive delete link more

Comments

2

So I've reconfigured with BUILD_SHARED_LIBS left unchecked in the CMake GUI, regenerated the VS project files, and then rebuilt the solution in release mode. Then (for good measure) rebuilt the install project. Still no .pyd file.See https://raw.githubusercontent.com/g40... for log from INSTALL build

g40 gravatar imageg40 ( 2020-01-18 09:35:23 -0600 )edit

what about R:/src/libs/opencv/build/lib/python3 ?

berak gravatar imageberak ( 2020-01-18 09:59:00 -0600 )edit
2

Nothing:

    R:\src\libs\opencv\build\lib>ls -R
.:
Debug  Release

./Debug:
opencv_calib3d420d.exp     opencv_features2d420d.pdb  opencv_imgproc420d.lib    opencv_stitching420d.exp
opencv_calib3d420d.lib     opencv_flann420d.exp       opencv_imgproc420d.pdb    opencv_stitching420d.lib
opencv_calib3d420d.pdb     opencv_flann420d.lib       opencv_ml420d.exp         opencv_stitching420d.pdb
opencv_core420d.exp        opencv_flann420d.pdb       opencv_ml420d.lib         opencv_ts420d.lib
opencv_core420d.lib        opencv_highgui420d.exp     opencv_ml420d.pdb         opencv_ts420d.pdb
opencv_core420d.pdb        opencv_highgui420d.lib     opencv_objdetect420d.exp  opencv_video420d.exp
opencv_dnn420d.exp         opencv_highgui420d.pdb     opencv_objdetect420d.lib  opencv_video420d.lib
...
g40 gravatar imageg40 ( 2020-01-18 10:43:03 -0600 )edit

thanks for the report. imho, we're safe to assume, it was never built at all ;(

can you check the build logs, put your cmake output somewhere (won't fit into a comment) ?

berak gravatar imageberak ( 2020-01-18 11:03:21 -0600 )edit

Hello berak. Thanks for the help here. Much appreciated. link text

g40 gravatar imageg40 ( 2020-01-18 11:09:16 -0600 )edit

thanks, but not quite -- the text in the cmake-gui box at the bottom (or what cmake would spit out on console)

berak gravatar imageberak ( 2020-01-18 11:12:35 -0600 )edit

aha. Interesting. Unavailable: gapi java js python2 python3

link text

g40 gravatar imageg40 ( 2020-01-18 11:20:45 -0600 )edit

you must have package numpy pylint flake8 and beatifulSoup before running cmake

LBerger gravatar imageLBerger ( 2020-01-18 11:23:05 -0600 )edit
1

@berak. I am no stranger to cmake foolishness. see link text

Thanks again.

g40 gravatar imageg40 ( 2020-01-18 11:23:12 -0600 )edit
1

@LBerger. OK thank you that might be helpful. From where should these packages be sourced and where installed? Please give more specific information. And bear in mind this is Windows. So nop 'sudo apt ...' luxuries :)

g40 gravatar imageg40 ( 2020-01-18 11:27:03 -0600 )edit
0

answered 2020-03-12 02:45:00 -0600

KTeddy gravatar image

If your python interpreter is not official, you can try the official version.
Details: I have used anaconda python to build opencv, but the same as your question, there isn't BUILD_opencv_python3 in cmake gui, as a result I can't get a .pyd file. I come across a comment that anaconda and cmake have compatibility problems. Finally I solved it by installing official python version.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-01-18 08:16:20 -0600

Seen: 2,638 times

Last updated: Mar 12 '20