Is it possible to run opencv (python binding) from a virtualenv?

前端 未结 4 1271
悲哀的现实
悲哀的现实 2020-12-05 02:45

I would like to keep everything contained within the virtualenv. Is this possible with OpenCV? I\'m fine with building from scratch, do I just need to setup the virtualenv

4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-05 03:03

    From opencv install guide :

    By default the OpenCV build system will choose the most recent version of Python that it can find, or you can force it to use a specific version using the PYTHON_EXECUTABLE variable when you invoke cmake.)

    I just installed it on my ubuntu 11.10, on virtual env --with-no-site-package, by following the instruction on the link above. you need to build whole opencv. and its python wrapper together.

    EDIT 1:

    1. Create a temporary directory, which we denote as , where you want to put the generated Makefiles, project files as well the object files and output binaries.

      cd ~/opencv
      mkdir release
      cd release
      cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
      
    2. Enter the created temporary directory () and proceed with:

      make
      sudo make install
      

    ---------

    after build & install add the extension modules on PYTHON_PATH

    export PYTHONPATH=~/projects/opencv/release/lib:$PYTHONPATH
    

提交回复
热议问题