简体   繁体   中英

UnsatisfiableError: The following specifications were found to be in conflict: - opencv3 -> python 2.7* - python 3.6*

How to install OpenCV for Anaconda Python in OS X? I used the same command in Windows 7 Enterprise and it worked

Monas-MacBook-Pro:machine_learning mona$ conda install --channel https://conda.anaconda.org/menpo opencv3
Fetching package metadata .............
Solving package specifications: .

UnsatisfiableError: The following specifications were found to be in conflict:
  - opencv3 -> python 2.7*
  - python 3.6*
Use "conda info <package>" to see the dependencies for each package.

Monas-MacBook-Pro:machine_learning mona$ conda install opencv3
Fetching package metadata ...........

PackageNotFoundError: Packages missing in current channels:

  - opencv3

We have searched for the packages in the following channels:

  - https://repo.continuum.io/pkgs/main/osx-64
  - https://repo.continuum.io/pkgs/main/noarch
  - https://repo.continuum.io/pkgs/free/osx-64
  - https://repo.continuum.io/pkgs/free/noarch
  - https://repo.continuum.io/pkgs/r/osx-64
  - https://repo.continuum.io/pkgs/r/noarch
  - https://repo.continuum.io/pkgs/pro/osx-64
  - https://repo.continuum.io/pkgs/pro/noarch


Monas-MacBook-Pro:machine_learning mona$ conda install -c menpo opencv3 
Fetching package metadata .............
Solving package specifications: .

UnsatisfiableError: The following specifications were found to be in conflict:
  - opencv3 -> python 2.7*
  - python 3.6*
Use "conda info <package>" to see the dependencies for each package.

Update: I even tried installing it using conda forge but I got this error

Monas-MacBook-Pro:machine_learning mona$ conda install -c conda-forge opencv 
Fetching package metadata .............
Solving package specifications: ^[[A^[[B.

Package plan for installation in environment /Users/mona/anaconda:

The following NEW packages will be INSTALLED:

    blas:         1.1-openblas          conda-forge
    bzip2:        1.0.6-1               conda-forge
    ffmpeg:       3.2.4-1               conda-forge
    x264:         20131217-3            conda-forge

The following packages will be UPDATED:

    h5py:         2.7.0-np112py36_0                 --> 2.7.1-py36_1                  conda-forge
    hdf5:         1.8.17-1                          --> 1.8.18-1                      conda-forge
    numpy:        1.12.1-py36_0                     --> 1.12.1-py36_blas_openblas_200 conda-forge [blas_openblas]
    opencv:       3.2.0-np112py36_0     conda-forge --> 3.3.0-py36_blas_openblas_200  conda-forge [blas_openblas]
    pytables:     3.3.0-np112py36_0                 --> 3.4.2-np112py36_1             conda-forge
    scikit-learn: 0.19.0-np112py36_0                --> 0.19.0-py36_blas_openblas_201 conda-forge [blas_openblas]
    scipy:        0.19.1-np112py36_0                --> 0.19.1-py36_blas_openblas_202 conda-forge [blas_openblas]

The following packages will be SUPERSEDED by a higher-priority channel:

    conda:        4.3.27-py36hb556a21_0             --> 4.3.24-py36_0                 conda-forge
    conda-env:    2.6.0-0                           --> 2.6.0-0                       conda-forge

Proceed ([y]/n)? y
Invalid choice:  y
Proceed ([y]/n)? y

bzip2-1.0.6-1. 100% |#####################################################| Time: 0:00:00 395.79 kB/s
conda-env-2.6. 100% |#####################################################| Time: 0:00:00 993.59 kB/s
x264-20131217- 100% |#####################################################| Time: 0:00:02   1.19 MB/s
ffmpeg-3.2.4-1 100% |#####################################################| Time: 0:00:25   1.60 MB/s
hdf5-1.8.18-1. 100% |#####################################################| Time: 0:00:03   1.31 MB/s
blas-1.1-openb 100% |#####################################################| Time: 0:00:00 816.40 kB/s
numpy-1.12.1-p 100% |#####################################################| Time: 0:00:02   1.52 MB/s
h5py-2.7.1-py3 100% |#####################################################| Time: 0:00:00   1.78 MB/s
scipy-0.19.1-p 100% |#####################################################| Time: 0:00:10   1.55 MB/s
pytables-3.4.2 100% |#####################################################| Time: 0:00:02   1.19 MB/s
scikit-learn-0 100% |#####################################################| Time: 0:00:04   1.32 MB/s
conda-4.3.24-p 100% |#####################################################| Time: 0:00:00   1.59 MB/s
opencv-3.3.0-p 100% |#####################################################| Time: 0:00:22   1.64 MB/s
Monas-MacBook-Pro:machine_learning mona$ python
Python 3.6.2 |Anaconda custom (x86_64)| (default, Jul 20 2017, 13:14:59) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dlopen(/Users/mona/anaconda/lib/python3.6/site-packages/cv2.cpython-36m-darwin.so, 2): Library not loaded: @rpath/libopenblasp-r0.2.19.dylib
  Referenced from: /Users/mona/anaconda/lib/libopencv_core.3.3.dylib
  Reason: image not found
>>> 

This is an exact duplicate of this question from a few weeks ago. Just to copy/paste the answer:

Have a look at the list of conda installers for OpenCV in under the menpo package on Anaconda's package list:

osx-64/opencv3-3.1.0-py27_0.tar.bz2
osx-64/opencv3-3.1.0-py34_0.tar.bz2
osx-64/opencv3-3.1.0-py35_0.tar.bz2
linux-64/opencv3-3.1.0-py35_0.tar.bz2
linux-64/opencv3-3.1.0-py27_0.tar.bz2
linux-64/opencv3-3.1.0-py36_0.tar.bz2
linux-64/opencv3-3.1.0-py34_0.tar.bz2
linux-64/opencv3-3.2.0-np111py35_0.tar.bz2
linux-64/opencv3-3.2.0-np111py34_0.tar.bz2
linux-64/opencv3-3.2.0-np111py27_0.tar.bz2
win-32/opencv3-3.1.0-py27_0.tar.bz2
win-64/opencv3-3.1.0-py35_0.tar.bz2
win-32/opencv3-3.1.0-py35_0.tar.bz2
win-64/opencv3-3.1.0-py34_0.tar.bz2
win-32/opencv3-3.1.0-py34_0.tar.bz2
win-64/opencv3-3.1.0-py27_0.tar.bz2

Notice the Python versions listed in each installer. For macOS, the newest menpo installer is OpenCV 3.1.0 and works on Python 3.5. So if you want to use the menpo installer, simply create a new environment with Python 3.5, activate, and then install:

conda create -n <opencv virtual env> python=3.5
source activate <opencv virtual env>
conda install -c menpo opencv3

Otherwise if you want to use Python 3.6 (which is a really great Python release), you'll need to build from source. See the great answer from this Stack Overflow question: Can't install OpenCV3 on Anaconda3 python3.6 on macOS .

Monas-MacBook-Pro:machine_learning mona$ conda create -n py35 python=3.5
Fetching package metadata .............
Solving package specifications: .

Package plan for installation in environment /Users/mona/anaconda/envs/py35:

The following NEW packages will be INSTALLED:

    ca-certificates: 2017.08.26-ha1e5d58_0     
    certifi:         2017.7.27.1-py35h0fdde5e_0
    libcxx:          4.0.1-h579ed51_0          
    libcxxabi:       4.0.1-hebd6815_0          
    libedit:         3.1-hb4e282d_0            
    libffi:          3.2.1-hd939716_3          
    ncurses:         6.0-ha932d30_1            
    openssl:         1.0.2l-h57f3a61_2         
    pip:             9.0.1-py35he52dd69_3      
    python:          3.5.4-hf91e954_15         
    readline:        7.0-h81b24a6_3            
    setuptools:      36.5.0-py35h52cde6a_0     
    sqlite:          3.20.1-h900c3b0_1         
    tk:              8.6.7-hcdce994_1          
    wheel:           0.29.0-py35ha7aa5c4_1     
    xz:              5.2.3-ha24016e_1          
    zlib:            1.2.11-h60db283_1         

Proceed ([y]/n)? y

ca-certificate 100% |#################################################################################################################| Time: 0:00:00   1.86 MB/s
tk-8.6.7-hcdce 100% |#################################################################################################################| Time: 0:00:01   2.17 MB/s
xz-5.2.3-ha240 100% |#################################################################################################################| Time: 0:00:00   2.33 MB/s
zlib-1.2.11-h6 100% |#################################################################################################################| Time: 0:00:00   3.35 MB/s
openssl-1.0.2l 100% |#################################################################################################################| Time: 0:00:01   2.04 MB/s
libffi-3.2.1-h 100% |#################################################################################################################| Time: 0:00:00 943.34 kB/s
ncurses-6.0-ha 100% |#################################################################################################################| Time: 0:00:00   1.90 MB/s
libedit-3.1-hb 100% |#################################################################################################################| Time: 0:00:00   1.18 MB/s
readline-7.0-h 100% |#################################################################################################################| Time: 0:00:00   1.36 MB/s
sqlite-3.20.1- 100% |#################################################################################################################| Time: 0:00:01   1.41 MB/s
python-3.5.4-h 100% |#################################################################################################################| Time: 0:00:07   1.72 MB/s
#
# To activate this environment, use:
# > conda activate py35
#
# To deactivate an active environment, use:
# > conda deactivate
#

Monas-MacBook-Pro:machine_learning mona$ conda activate py35

CommandNotFoundError: 'activate is not a conda command.
Did you mean 'source activate'?


Monas-MacBook-Pro:machine_learning mona$ source activate py35
(py35) Monas-MacBook-Pro:machine_learning mona$ conda install -c menpo opencv3
Fetching package metadata ...............
Solving package specifications: .

Package plan for installation in environment /Users/mona/anaconda/envs/py35:

The following NEW packages will be INSTALLED:

    hdf5:         1.8.18-h1edb405_0          
    intel-openmp: 2018.0.0-hdd0ccc9_7        
    libgfortran:  3.0.1-h93005f0_2           
    mkl:          2018.0.0-hc285769_4        
    numpy:        1.13.1-py35he58e7f4_2      
    opencv3:      3.1.0-py35_0          menpo
    tbb:          4.3_20141023-0        menpo

Proceed ([y]/n)? y

intel-openmp-2 100% |#################################################################################################################| Time: 0:00:00   1.81 MB/s
libgfortran-3. 100% |#################################################################################################################| Time: 0:00:00   1.71 MB/s
tbb-4.3_201410 100% |#################################################################################################################| Time: 0:00:00   1.66 MB/s
mkl-2018.0.0-h 100% |#################################################################################################################| Time: 0:01:33   1.66 MB/s
hdf5-1.8.18-h1 100% |#################################################################################################################| Time: 0:00:02   1.72 MB/s
numpy-1.13.1-p 100% |#################################################################################################################| Time: 0:00:03   1.15 MB/s
opencv3-3.1.0- 100% |#################################################################################################################| Time: 0:00:46 847.84 kB/s
(py35) Monas-MacBook-Pro:machine_learning mona$ python
Python 3.5.4 |Anaconda, Inc.| (default, Sep 30 2017, 13:45:16) 
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> 

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