opencv安装教程python中不是内部指令,如何安装没有导入cv2错误的openCV_python?

I am trying to install the OpenCV-python on my mac and i have used the following:

$pip install opencv-python

which gave me the following error:

$pip install opencv-python

Collecting opencv-python

Using cached opencv_python-3.4.0.12-cp27-cp27m macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl

Collecting numpy>=1.11.1 (from opencv-python)

Using cached numpy-1.14.2-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl

matplotlib 1.3.1 requires nose, which is not installed.

matplotlib 1.3.1 requires tornado, which is not installed.

Installing collected packages: numpy, opencv-python

Found existing installation: numpy 1.8.0rc1

Cannot uninstall 'numpy'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

Then i did try the pip install --upgrade matplotlib which didnot change anything. It just show me:

matplotlib 2.2.2 requires backports.functools-lru-cache, which is not installed.

matplotlib 2.2.2 has requirement numpy>=1.7.1, but you'll have numpy 1.8.0rc1 which is incompatible.

and I installed on my other mac but i got import cv2 problem alot in my codes.

I will be more than happy if anyone have a good solution or recommendation to install the openCV-python.

Thanks

解决方案

In summary, macOS comes with the Python preinstalled and you should not mess with the packages installed as some system utilities depend on them.

The Apple-provided build of Python is installed in /System/Library/Frameworks/Python.framework and /usr/bin/python, respectively. You should never modify or delete these, as they are Apple-controlled and are used by Apple- or third-party software. Remember that if you choose to install a newer Python version from python.org, you will have two different but functional Python installations on your computer, so it will be important that your paths and usages are consistent with what you want to do.

You should take a look on either venv or virtualenv.

You can read this answer: https://stackoverflow.com/a/41972262/4796844 that will get you through the basics.

In a nutshell, to solve your problem:

$ python3 -m venv ./project-name

$ . ./project-name/bin/activate

$ pip install opencv-python

And to leave the virtual environment, simply:

$ deactivate

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值