将预安装的Opencv用于多个虚拟环境

时间:2020-03-13 22:26:01

标签: python opencv virtualenv nvidia-jetson-nano

我在Jetson Nano上使用Jetpack 4.3(Nvidia Jetson卡的操作系统映像)。其中预装有OpenCV 4.1.1。
我想在多个虚拟环境中工作,但是我不想在我创建的每个虚拟环境中安装(从源代码)OpenCV。.
因此,由于OpenCV已预先安装在虚拟环境之外,是否有可能在我创建的每个虚拟环境中使用它?
如果是这样,如何将OpenCV安装链接到虚拟环境?

其他信息:

dpkg -L libopencv

返回:

/usr
/usr/lib
/usr/lib/aarch64-linux-gnu
/usr/lib/aarch64-linux-gnu/libopencv_calib3d.so.4.1.1
/usr/lib/aarch64-linux-gnu/libopencv_core.so.4.1.1
/usr/lib/aarch64-linux-gnu/libopencv_dnn.so.4.1.1
/usr/lib/aarch64-linux-gnu/libopencv_features2d.so.4.1.1
/usr/lib/aarch64-linux-gnu/libopencv_flann.so.4.1.1
/usr/lib/aarch64-linux-gnu/libopencv_gapi.so.4.1.1
/usr/lib/aarch64-linux-gnu/libopencv_highgui.so.4.1.1
/usr/lib/aarch64-linux-gnu/libopencv_imgcodecs.so.4.1.1
/usr/lib/aarch64-linux-gnu/libopencv_imgproc.so.4.1.1
/usr/lib/aarch64-linux-gnu/libopencv_ml.so.4.1.1
/usr/lib/aarch64-linux-gnu/libopencv_objdetect.so.4.1.1
/usr/lib/aarch64-linux-gnu/libopencv_photo.so.4.1.1
/usr/lib/aarch64-linux-gnu/libopencv_stitching.so.4.1.1
/usr/lib/aarch64-linux-gnu/libopencv_video.so.4.1.1
/usr/lib/aarch64-linux-gnu/libopencv_videoio.so.4.1.1
/usr/share
/usr/share/opencv4
/usr/share/opencv4/haarcascades
/usr/share/opencv4/haarcascades/haarcascade_eye.xml
/usr/share/opencv4/haarcascades/haarcascade_eye_tree_eyeglasses.xml
/usr/share/opencv4/haarcascades/haarcascade_frontalcatface.xml
/usr/share/opencv4/haarcascades/haarcascade_frontalcatface_extended.xml
/usr/share/opencv4/haarcascades/haarcascade_frontalface_alt.xml
/usr/share/opencv4/haarcascades/haarcascade_frontalface_alt2.xml
/usr/share/opencv4/haarcascades/haarcascade_frontalface_alt_tree.xml
/usr/share/opencv4/haarcascades/haarcascade_frontalface_default.xml
/usr/share/opencv4/haarcascades/haarcascade_fullbody.xml
/usr/share/opencv4/haarcascades/haarcascade_lefteye_2splits.xml
/usr/share/opencv4/haarcascades/haarcascade_licence_plate_rus_16stages.xml
/usr/share/opencv4/haarcascades/haarcascade_lowerbody.xml
/usr/share/opencv4/haarcascades/haarcascade_profileface.xml
/usr/share/opencv4/haarcascades/haarcascade_righteye_2splits.xml
/usr/share/opencv4/haarcascades/haarcascade_russian_plate_number.xml
/usr/share/opencv4/haarcascades/haarcascade_smile.xml
/usr/share/opencv4/haarcascades/haarcascade_upperbody.xml
/usr/share/opencv4/lbpcascades
/usr/share/opencv4/lbpcascades/lbpcascade_frontalcatface.xml
/usr/share/opencv4/lbpcascades/lbpcascade_frontalface.xml
/usr/share/opencv4/lbpcascades/lbpcascade_frontalface_improved.xml
/usr/share/opencv4/lbpcascades/lbpcascade_profileface.xml
/usr/share/opencv4/lbpcascades/lbpcascade_silverware.xml
/usr/lib/aarch64-linux-gnu/libopencv_calib3d.so.4.1
/usr/lib/aarch64-linux-gnu/libopencv_core.so.4.1
/usr/lib/aarch64-linux-gnu/libopencv_dnn.so.4.1
/usr/lib/aarch64-linux-gnu/libopencv_features2d.so.4.1
/usr/lib/aarch64-linux-gnu/libopencv_flann.so.4.1
/usr/lib/aarch64-linux-gnu/libopencv_gapi.so.4.1
/usr/lib/aarch64-linux-gnu/libopencv_highgui.so.4.1
/usr/lib/aarch64-linux-gnu/libopencv_imgcodecs.so.4.1
/usr/lib/aarch64-linux-gnu/libopencv_imgproc.so.4.1
/usr/lib/aarch64-linux-gnu/libopencv_ml.so.4.1
/usr/lib/aarch64-linux-gnu/libopencv_objdetect.so.4.1
/usr/lib/aarch64-linux-gnu/libopencv_photo.so.4.1
/usr/lib/aarch64-linux-gnu/libopencv_stitching.so.4.1
/usr/lib/aarch64-linux-gnu/libopencv_video.so.4.1
/usr/lib/aarch64-linux-gnu/libopencv_videoio.so.4.1

1 个答案:

答案 0 :(得分:1)

正确的方法是创建带有标志的虚拟环境以包含系统范围的包:python3 -m venv --system-wide-packages .venv

下面的回答详细解释了这个过程,包括如何处理pip install:https://stackoverflow.com/a/19459977/804840