2

I've been attempting to install OpenCV with Conda using Python 3.5, but I've encountered difficulties. I have already explored a solution suggested online, but it didn't work for me. I suspect that the problem might be due to OpenCV not being supported by Python 3.5.

Maybe one of you knows a solution? Or, do I have to use an earlier version of Python (v2.7)?

Gykonik
  • 638
  • 1
  • 7
  • 24

3 Answers3

2

I have installed OpenCV using python 2.7 version.

You have to use the command conda install opencv in the command prompt.

If you want a particular version of OpenCV mention the version as follows:

conda install opencv=3.0.0
Jeru Luke
  • 20,118
  • 13
  • 80
  • 87
  • Yeah, but I have python 3.5 and not 2.7... Can I install 3.5 and 2.7 at the same time with Spyder/Anaconda? – Gykonik Jan 28 '17 at 14:10
  • @Niklas Did you try it? Stop arguing without trying it first. And sure you can. Anaconda's environments are there for this. (Hint: Python 3 + the install above just works fine; but not for python 3.6 (for the moment)!) (I also recommend skimming through anaconda's docs for a moment. These might give you some idea on why your other approaches did not work and how to install different versions of python) – sascha Jan 28 '17 at 14:11
  • @Niklas just try the command in the **anaconda command prompt** first and let us know. – Jeru Luke Jan 28 '17 at 14:12
  • 1
    Okay, I got it! For me it worked with "conda install -c https://conda.anaconda.org/menpo opencv3" – Gykonik Jan 28 '17 at 14:14
  • @Niklas That's not what was proposed. It's not recommended. Not sure, why you ignore other experienced users. There are base-repos and unoffical repos. You did use an unofficial one. If that's okay for you, do it. – sascha Jan 28 '17 at 14:15
  • I also recommend you to go through [THIS SO PAGE](http://stackoverflow.com/questions/23119413/how-to-install-python-opencv-through-conda) – Jeru Luke Jan 28 '17 at 14:18
  • Dude, did u read my post? I linked it in my original post and said, THAT I READ IT! -.- – Gykonik Jan 28 '17 at 14:23
  • @Niklas Sorry wasn't paying close attention. Still glad I could help. – Jeru Luke Jan 28 '17 at 14:43
1

i just use below command, and it works for me. ( windows 10 pro 64-bit, Anaconda 4.6.8, Spyder 3.3.2)

(base) C:\Windows\system32> conda install opencv

output like this:

=============================================

Collecting package metadata: done

Solving environment: done

Package Plan

environment location: C:\ProgramData\Anaconda3

added / updated specs: - opencv

The following packages will be downloaded:

package                    |            build
---------------------------|-----------------
libopencv-3.4.1            |       h875b8b8_3        37.0 MB
opencv-3.4.1               |   py37h6fd60c2_3           9 KB
py-opencv-3.4.1            |   py37h1b0d24d_3         1.5 MB
------------------------------------------------------------
                                       Total:        38.5 MB

The following NEW packages will be INSTALLED:

libopencv pkgs/main/win-64::libopencv-3.4.1-h875b8b8_3

opencv pkgs/main/win-64::opencv-3.4.1-py37h6fd60c2_3

py-opencv pkgs/main/win-64::py-opencv-3.4.1-py37h1b0d24d_3

Proceed ([y]/n)? y

Downloading and Extracting Packages

py-opencv-3.4.1 | 1.5 MB | ################################### | 100%

opencv-3.4.1 | 9 KB | ################################### | 100%

libopencv-3.4.1 | 37.0 MB | ################################### | 100%

Preparing transaction: done

Verifying transaction: done

Executing transaction: done

============================================================================

finally, i tested it in IPython console and Spyder editor and run, both of them works fine.

Mike Xue
  • 31
  • 4
0

The use of conda install, as posted earlier, is the way I would prefer. However, if it didn't work, you might consider using Homebrew, as outline in this webpage.

## Install latest Homebrew, if haven't already
which brew #command line; check if installed
## Run the line below in command line terminal
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

## Since you already have python3, no installation necessary
## Install gcc
brew install gcc
## Install necessary python packages
sudo pip3 install -U numpy scipy matplotlib scikit-learn scikit-image

## OpenCV3, specific for python 3
## and "register" to your machine
brew install opencv3 --with-python3
ln -s /usr/local/opt/opencv3/lib/python3.5/site-packages/cv2.cpython-35m-darwin.so /usr/local/lib/python3.5/site-packages/
David C.
  • 1,974
  • 2
  • 19
  • 29