Installing OpenCV for all conda environments

女生的网名这么多〃 提交于 2020-01-13 19:25:31

问题


I have an Ubuntu 16.04 system with an Anaconda installation. I want to compile and install OpenCV 3.3 and use also the Python bindings. I used the following CMake command:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_CUDA=ON -D D WITH_FFMPEG=1 -D WITH_CUBLAS=ON -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D INSTALL_PYTHON_EXAMPLES=ON -D INSTALL_C_EXAMPLES=OFF -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.3.0/modules -D BUILD_EXAMPLES=ON -D BUILD_TIFF=ON -D PYTHON_EXECUTABLE=/home/guel/anaconda2/envs/py27/bin/python -D PYTHON2_LIBRARIES=/home/guel/anaconda2/envs/py27/lib/libpython2.7.so -D PYTHON2_PACKAGES_PATH=/home/guel/anaconda2/envs/py27/lib/python2.7/site-packages -DWITH_EIGEN=OFF -D BUILD_opencv_cudalegacy=OFF ..

The command does the job but then, of course, OpenCV is installed only for a specific conda environment that I created. However, I want to be able to use it also from different environments without having to go through the compilation for each and every environment. Is there a way to achieve that in a simple way? Since the OpenCv libraries are actually installed in /usr/local, I can imagine that there must be a simple way to link the libraries to each new conda enviroment but I couldn't figure out exactly how.


回答1:


OpenCV 3.3 for python 2.7 and 3.6 on linux are available from conda repository. You may not need to compile yourself. Just use conda command to install it to your environement.

See this

  1. https://anaconda.org/conda-forge/opencv for the commands.
    • conda install -c conda-forge -n env opencv or
    • conda install -c conda-forge/label/broken -n env opencv
    • where env is your conda virtual environment name
  2. https://anaconda.org/conda-forge/opencv/files for detailed files on python version and OS.

Hope this help.




回答2:


So you are providing the python package and library path to environment specific location, in order to make it available environment try using the anaconda/bin and lib path. Can't make it as a comment due to low reputation.



来源:https://stackoverflow.com/questions/46339134/installing-opencv-for-all-conda-environments

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!