[英]OpenCV in python on mac installation with homebrew
I'm trying to get opencv for python on my mac running mavericks. 我正试图在运行mavericks的mac上获得opencv for python。 After googling/stack overflow seraching I tried:
谷歌搜索/堆栈溢出搜索后,我试过:
brew install homebrew/science/opencv
Based on the terminal output it looks like that worked. 基于终端输出,它看起来像是有效的。
To verify I wrote a python script that simply contains: 为了验证我写了一个只包含以下内容的python脚本:
import cv2
print("Hello")
I get no module named cv2
. 我
no module named cv2
得到no module named cv2
。 When I try looking at the installed modules by typing help('modules')
I don't see cv or cv2. 当我尝试通过键入
help('modules')
查看已安装的模块时,我看不到cv或cv2。 This leaves me with two conclusions: either I didn't properly install opencv or import cv2
isn't actually importing cv2 and python is looking in the wrong location for cv2. 这给我留下了两个结论:要么我没有正确安装opencv,要么
import cv2
实际上并没有导入cv2而python正在寻找cv2的错误位置。 Any suggestions would be appreciated. 任何建议,将不胜感激。
根据本指南 ,如果您将以下内容添加到.bash_profile
它应该可以解决您的问题:
export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH
You could update your pythonpath, but you would probably be better served running 'brew install python' so that you are not using system python. 你可以更新你的python路径,但你可能会更好地运行'brew install python',这样你就不会使用系统python。 System python and brewed python look for modules in different locations.
System python和brewed python在不同的位置寻找模块。
EDIT: Asked questions, updated the above. 编辑:提问,更新以上内容。
This worked for me. 这对我有用。 Install X code from App Store.
从App Store安装X代码。
conda install -c menpo opencv3
conda install -c menpo opencv3
安装OpenCV It should be good to go. 去吧应该不错。 Remember import it as
import cv2
In case of any library errors try this conda install -c conda-forge basemap fiona
请记住将其导入为
import cv2
如果出现任何库错误,请尝试此conda install -c conda-forge basemap fiona
import cv2
conda install -c conda-forge basemap fiona
Hope it helped 希望它有所帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.