简体   繁体   中英

How to import opencv into python project using spyder in Mac?

I am trying to use OpenCV in a Python project in Spyder, I wanted to know if there is any way to install it as a package in spyder.

Thanks in advance.

For Mac. Open terminal.

conda install -c menpo opencv3

In windows.

  1. Choose your distro, python ver and system at: http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv

And download the .whl to a folder of your choice. For instance I chose the 5th from the bottom of the opencv list because I have python 3.6 on a 64 bit OS.

  1. Open command prompt, go to the folder, and type

    pip install opencv(ver).whl

Where (Ver) indicates the file you just downloaded.

Run python and try and import cv2. If it works you succeeded.

From the error message it stated:

python 3.6* Use "conda info " to see the dependencies for each package"

It looks that you are using Python 3.6 in your MAC machine. The conda install command below will get the OpenCV 3.2.0 for 64-bit OSX for you which is just released two days ago in conda-forge repository here .

conda install -c conda-forge opencv=3.2.0 

The menpo repository here only has OpenCV 3.1.0 for Python 2.7, 3.4 and 3.5 for osx-64 at the moment.

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