name 'cv' is not defined
Gil-W opened this issue · 3 comments
Working on a Mac with brew installed utilities and I am getting this error message (from the sample code):
gil$ python foo.py
Traceback (most recent call last):
File "foo.py", line 14, in
inp = cv.LoadImage("source.bmp")
NameError: name 'cv' is not defined
I had a bunch of issues around not having cv at all but seemed to have fixed that with:
brew install homebrew/science/opencv
....
==> Installing opencv
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/science/ope
################################################################## 100.0%
==> Pouring opencv-2.4.10.1.yosemite.bottle.tar.gz
I could be barking up the wrong tree entirely :-(
Hello. I have never worked on Mac, so I am not really aware of how it is meant to work. Can you import cv from the interactive shell ? "cv" is the old syntax try import cv2, maybe the mac version of opencv got rid of the old syntax. If it doesn't the problem is coming from your installation.
Mac
- Reinstall brew.
rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- Install opencv
brew tap homebrew/science
brew install opencv
- Add the packages to python
mkdir -p $HOME/Library/Python/2.7/lib/python/site-packages
echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")' >> $HOME/Library/Python/2.7/lib/python/site-packages/homebrew.pth
Thank you @Buggaboo for this enlightenment 😉