Ubuntu18.04同时配置python3-opencv和python2-opencv

注:可只为python2配置opencv,只看步骤1,只为python3配置opencv只看步骤2

1.先为python2配置opencv和opencv-contrib

pip install opencv-python
pip install opencv-contrib-python

2.再为python3配置opencv和opencv-contrib

pip3 install opencv-python
pip3 install opencv-contrib-python

问题:在为python3配置opencv和contrib的时候总是报错:

解决:

先删除 home/zhoujie/.local/lib/python3.6/site-packages/ 中的numpy包和matplotlib包,再重新安装

怎么进“.”开头的隐藏文件夹呢?

Ubuntu18.04同时配置python3-opencv和python2-opencv_第1张图片

右边那个显示隐藏文件夹打钩就可以

手动删除numpy包和matplot包,没有就不删

安装numpy和matplot包:

pip3 install numpy
pip3 install matplotlib

再安装python3-opencv

pip3 install opencv-python
pip3 install opencv-contrib-python

3.测试

Ubuntu18.04同时配置python3-opencv和python2-opencv_第2张图片

python3.6 成功

Ubuntu18.04同时配置python3-opencv和python2-opencv_第3张图片

python2.7 成功

你可能感兴趣的:(安装)