Help us understand the problem. What is going on with this article?

Ubuntu + Anaconda + python3 にてOpenCVをcondaでインストール

More than 1 year has passed since last update.

環境

  • Ubuntu : 16.04.1
  • Anaconda : 4.5.1
  • Anaconda Navigator : 1.8.3
  • Python : 3.6.5

Anaconda Navigatorでの操作

Screenshot from 2018-04-29 06-36-20.png

  1. Anaconda Navigator を起動
  2. 左メニューのEnvironmentから新規の仮想環境「openCV」という名前で作成する Python3.6環境で作成
  3. 作成した「openCV」を選択して、実行ボタンをクリックして「Open Terminal」を実行

起動したターミナル上でcondaを使いOpenCVをインストール

(openCV) ariki@vivo-ubuntu:~$ conda install -c menpo opencv

## Package Plan ##

  environment location: /home/ariki/anaconda3/envs/openCV

  added / updated specs: 
    - opencv


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    libxml2-2.9.8              |       hf84eae3_0         2.0 MB
    harfbuzz-1.7.6             |       h5f0a787_1         807 KB
    numpy-1.14.2               |   py36hdbf6ddf_1         4.1 MB
    fontconfig-2.12.6          |       h49f89f6_0         283 KB
    graphite2-1.3.11           |       hf63cedd_1         126 KB
    libprotobuf-3.4.1          |       h5b8497f_0         4.0 MB
    mkl_fft-1.0.1              |   py36h3010b51_0         140 KB
    mkl_random-1.0.1           |   py36h629b387_0         373 KB
    ffmpeg-3.4                 |       h7264315_0         8.0 MB
    libxcb-1.13                |       h1bed415_1         502 KB
    jasper-1.900.1             |       hd497a04_4         279 KB
    libgfortran-ng-7.2.0       |       hdf63c60_3         1.2 MB
    libvpx-1.6.1               |       h888fd40_0         2.3 MB
    mkl-2018.0.2               |                1       205.2 MB
    intel-openmp-2018.0.0      |                8         620 KB
    glib-2.56.1                |       h000015b_0         5.0 MB
    libopus-1.2.1              |       hb9ed12e_0         382 KB
    cairo-1.14.12              |       h7636065_2         1.3 MB
    pcre-8.42                  |       h439df22_0         251 KB
    opencv-3.3.1               |   py36h6cbbc71_1        38.9 MB
    ------------------------------------------------------------
                                           Total:       275.7 MB

The following NEW packages will be INSTALLED:

    bzip2:          1.0.6-h9a117a8_4     
    cairo:          1.14.12-h7636065_2   
    ffmpeg:         3.4-h7264315_0       
    fontconfig:     2.12.6-h49f89f6_0    
    freetype:       2.8-hab7d2ae_1       
    glib:           2.56.1-h000015b_0    
    graphite2:      1.3.11-hf63cedd_1    
    harfbuzz:       1.7.6-h5f0a787_1     
    hdf5:           1.10.1-h9caa474_1    
    icu:            58.2-h9c2bf20_1      
    intel-openmp:   2018.0.0-8           
    jasper:         1.900.1-hd497a04_4   
    jpeg:           9b-h024ee3a_2        
    libgfortran-ng: 7.2.0-hdf63c60_3     
    libopus:        1.2.1-hb9ed12e_0     
    libpng:         1.6.34-hb9fc6fc_0    
    libprotobuf:    3.4.1-h5b8497f_0     
    libtiff:        4.0.9-h28f6b97_0     
    libvpx:         1.6.1-h888fd40_0     
    libxcb:         1.13-h1bed415_1      
    libxml2:        2.9.8-hf84eae3_0     
    mkl:            2018.0.2-1           
    mkl_fft:        1.0.1-py36h3010b51_0 
    mkl_random:     1.0.1-py36h629b387_0 
    numpy:          1.14.2-py36hdbf6ddf_1
    opencv:         3.3.1-py36h6cbbc71_1 
    pcre:           8.42-h439df22_0      
    pixman:         0.34.0-hceecf20_3    

Proceed ([y]/n)? y


Downloading and Extracting Packages
libxml2 2.9.8: ######################################################### | 100% 
harfbuzz 1.7.6: ######################################################## | 100% 
numpy 1.14.2: ########################################################## | 100% 
fontconfig 2.12.6: ##################################################### | 100% 
graphite2 1.3.11: ###################################################### | 100% 
libprotobuf 3.4.1: ##################################################### | 100% 
mkl_fft 1.0.1: ######################################################### | 100% 
mkl_random 1.0.1: ###################################################### | 100% 
ffmpeg 3.4: ############################################################ | 100% 
libxcb 1.13: ########################################################### | 100% 
jasper 1.900.1: ######################################################## | 100% 
libgfortran-ng 7.2.0: ################################################## | 100% 
libvpx 1.6.1: ########################################################## | 100% 
mkl 2018.0.2: ########################################################## | 100% 
intel-openmp 2018.0.0: ################################################# | 100% 
glib 2.56.1: ########################################################### | 100% 
libopus 1.2.1: ######################################################### | 100% 
cairo 1.14.12: ######################################################### | 100% 
pcre 8.42: ############################################################# | 100% 
opencv 3.3.1: ########################################################## | 100% 
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

OpenCVがインストールできたかどうか確認

(openCV) ariki@vivo-ubuntu:~$ python

$ python
Python 3.6.5 |Anaconda, Inc.| (default, Apr 26 2018, 13:46:40)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'3.3.1'

Windows10、macOS High Sierraの環境でも同様の環境構築が可能

Windows10、macOS High Sierraであっても、Anacondaさえインストールをすれば、上記と同じ手順で、OpenCVの環境が構築できることを確認しました。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away