gpt4 book ai didi

python - opencv 安装在 mac 上但无法通过 python 控制台使用它

转载 作者:太空宇宙 更新时间:2023-11-03 21:52:32 25 4
gpt4 key购买 nike

无法在 macbook OS X Yosemite Ver 10.10.5 中安装“opencv”

尝试默认安装,没有帮助,然后我安装了 Python 的 Anaconda 发行版,之后再次尝试以下,我收到消息说 opencv 已安装,但我无法通过 python 控制台使用它。安装 Anaconda 后,我关注了 this tutorial安装opencv

  $sudo chmod 777 /usr/local/include/
$brew link eigen jpeg libpng libtiff ilmbase openexr numpy
$sudo chmod 777 /usr/local/lib/pkgconfig
$brew link eigen jpeg libpng libtiff ilmbase openexr numpy
$brew install opencv --evn=std
$brew link eigen jpeg libpng libtiff ilmbase openexr numpy
$sudo chmod 777 /usr/local/lib/
$brew link eigen jpeg libpng libtiff ilmbase openexr numpy
$brew install opencv --evn=std
$python
$mkdir -p /Users/vikramchindam1/.local/lib/python2.7/site-packages
$echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")' >> /Users/vikramchindam1/.local/lib/python2.7/site-packages/homebrew.pth

然后启动python控制台

 $python

>>> import cv
Python 2.7.11 |Anaconda 2.5.0 (x86_64)| (default, Dec 6 2015, 18:57:58)

[GCC 4.2.1 (Apple Inc. build 5577)] on darwin

Type "help", "copyright", "credits" or "license" for more information.

Anaconda is brought to you by Continuum Analytics.

Please check out: http://continuum.io/thanks and https://anaconda.org

>>> import cv

Traceback (most recent call last):

File "<stdin>", line 1, in <module>

ImportError: No module named cv

我在一段时间内多次安装了 Anaconda,这是个问题吗?以下是我的 .bash_profile 中的条目

alias textedit='open -a TextEdit'

# added by Anaconda 2.2.0 installer
export PATH="/Users/vikramchindam1/anaconda/bin:$PATH"

##
# Your previous /Users/vikramchindam1/.bash_profile file was backed up as /Users/vikramchindam1/.bash_profile.macports-saved_2015-06-06_at_15:09:19
##

# MacPorts Installer addition on 2015-06-06_at_15:09:19: adding an appropriate PATH variable for use with MacPorts.
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
# Finished adapting your PATH environment variable for use with MacPorts.


# added by Anaconda 2.2.0 installer
export PATH="/Applications/anaconda/bin:$PATH"

# added by Anaconda3 2.3.0 installer
export PATH="/Users/vikramchindam1/Documents/Anaconda-3/anaconda/bin:$PATH"

# added by Miniconda2 3.19.0 installer
export PATH="/Users/vikramchindam1/miniconda2/bin:$PATH"

# added by Anaconda2 2.5.0 installer
export PATH="/Users/vikramchindam1/Installations/Anacon-Python2-7/anaconda/bin:$PATH"
export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH

最后一个条目“export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH”是我在通过此命令“brew install opencv --env=std”安装 opencv 后添加的

请帮助我,在此先感谢。

最佳答案

您必须使用“conda”工具在 Anaconda 中安装 OpenCV。您可以尝试在您的终端中输入此内容。

conda install -c https://conda.binstar.org/menpo opencv

这适用于我的 ubuntu 14.04,我认为它也应该适用于 Mac。

您可以在此链接中找到详细说明,我在其中展示了如何在 Anaconda 中安装 OpenCV。

http://stackoverflow.com/questions/38787748/installing-opencv-3-1-with-anaconda-python3/39240127#39240127

希望对你有帮助 =)

关于python - opencv 安装在 mac 上但无法通过 python 控制台使用它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35930947/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com