如何安装没有导入cv2错误的openCV_python? [英] how to install openCV_python with no import cv2 error?

查看:1065
本文介绍了如何安装没有导入cv2错误的openCV_python?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Mac上安装OpenCV-python,并且使用了以下内容:

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

$ pip安装opencv-python

$pip install opencv-python

这给了我以下错误:

$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.

然后我确实尝试了pip install --upgrade matplotlib,它没有改变任何东西.它只是告诉我:

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.

我发现了许多在互联网上安装openCV-python的方法,例如: https ://www.pyimagesearch.com/2015/06/15/install-opencv-3-0-and-python-2-7-on-osx/

As I found many ways to install the openCV-python in the internet like: https://www.pyimagesearch.com/2015/06/15/install-opencv-3-0-and-python-2-7-on-osx/

,我在其他Mac上安装了代码,但是在代码中出现了很多导入cv2问题. 如果有人有一个好的解决方案或建议来安装openCV-python,我将非常高兴.

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.

谢谢

推荐答案

总而言之,macOS预先安装了Python,因此您不应该对已安装的软件包感到困惑,因为某些系统实用程序依赖它们.

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

https://docs.python.org/3.7/using/mac.html

Apple提供的Python构建版本分别安装在/System/Library/Frameworks/Python.framework和/usr/bin/python中.您绝对不要修改或删除这些内容,因为它们是Apple控制的,并由Apple或第三方软件使用.请记住,如果您选择从python.org安装较新的Python版本,则您的计算机上将安装两个不同但功能正常的Python安装,因此,确保路径和用法与您要执行的操作保持一致非常重要. >

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.

您应该查看 venv virtualenv .

您可以阅读以下答案: https://stackoverflow.com/a/41972262/4796844 可以帮助您通过基础知识.

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

这篇关于如何安装没有导入cv2错误的openCV_python?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆