conda can't find cv2 lib located at /opt/conda/python/3.6/cv2.cpython-36m-x86_64-linux-gnu.so
I have compiled opencv from source and used following flag to install it in anaconda lib path
-DCMAKE_INSTALL_PREFIX=/opt/conda -DCMAKE_BUILD_TYPE=Release (blah blah)
after running make install
the opencv lib gets installed at /opt/conda/python/3.6/cv2.cpython-36m-x86_64-linux-gnu.so
which is a bit strange as I was expecting to be installed in /opt/conda/lib
directory. More importantly when I try to do import cv2
inside python terminal, I get a ModuleNotFoundError
error. OpenCV is also not showing in conda list
. Am I missing something here? Where should OpenCV be installed to get it imported in Ananconda ?
For completeness my LD_LIBRARY_PATH
and PATH
are given below:
LD_LIBRARY_PATH= /opt/conda/lib:/usr/local/nvidia/lib:/usr/local/nvidia/lib64
PATH=/opt/conda/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PS: I am able to import OpenCV in Anaconda after doing cp /opt/conda/python/3.6/cv2.cpython-36m-x86_64-linux-gnu.so /opt/conda/lib/python3.6/site-packages/cv2.so
but this is not a proper solution as I have to do it after each compilation. What CMAKE_INSTALL_PREFIX
should I set to get it installed at the right place.
which opencv version is it ?
Branch = 4.0.0-rc
-DCMAKE_INSTALL_PREFIX is only for the c++ libs, not for your python so.
btw, did you build it with
-DBUILD_SHARED_LIBS=OFF
? (you should, so it does not depend on other opencv libs / so's later)Ohh. Did it change in 4.0.0 or it was always this way? Secondly, is there any separate flag for python installation directory?
ATM I used
-DBUILD_SHARED_LIBS=ON
. But I can recompile with-DBUILD_SHARED_LIBS=OFF
. I am still a bit lost about python installation path. Is there any proper way to get libraries installed in right directory of Anaconda?it was always like this
hmm, it should get inferred by looking at your python install. unfortunately, conda differs a lot from what "ordinary" snakes do there.
also , there were a couple of changes in the detection / installl process recently, you'll probably have to scan the github pr backlog here
conda differs a lot from what "ordinary" snakes do there.
That's true. But this conda snake is getting sharper each day; (Intel MKL supported NUMPY distributions etc.) So adding conda supported flags etc will help the community.
Thanks for pointing the direction. I'll go through the PRs and will see if I can find something helpful.
https://github.com/opencv/opencv/issu...