且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何安装没有导入cv2错误的openCV_python?

更新时间:2022-06-17 10:09:24

总而言之,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://***.com/a/41972262/4796844 可以帮助您通过基础知识.

You can read this answer: https://***.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