简体   繁体   中英

Mac OSX $python3 test_imagenet.py --image images/dog_beagle.png ImportError: No module named 'cv2'

I am using the tutorial found here

The error I get on the command line and for the Pycharm IDE is that cv2 can't be installed. Is this a problem because I am using a Macbook or can this be solved?

If the error is saying "no module named cv2", you need to install OpenCV. You can do this with homebrew using brew install opencv

For detailed instructions, take a look at: http://www.mobileway.net/2015/02/14/install-opencv-for-python-on-mac-os-x/


MORE INFO:

With opencv installed with brew, you just need to know the package location. Go to /usr/local/Cellar/opencv/ to find out your version number. I just installed with brew and have 2.4.13.

Once you know that, navigate to your Python directory with cd /Library/Python/2.7/site-packages/

You can then run each of these to link them up to Python:

ln -s /usr/local/Cellar/opencv/2.4.13/lib/python2.7/site-packages/cv.py cv.py
ln -s /usr/local/Cellar/opencv/2.4.13/lib/python2.7/site-packages/cv2.so cv2.so

(replace the 2.4.13 with the version number you have)

Hope that helps. I don't think it will be any easier with Windows, though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM