LoginSignup
1
3

More than 3 years have passed since last update.

【備忘録】PythonにOpenCVが導入できなかった時

Last updated at Posted at 2019-09-20

はじめに

 PythonでOpenCVを使いたいと思ったが、簡単にインストールできなかったので忘れないためにメモ。

症状

pip install opencv-pythonでのインストールができなかった

当時の環境

​ Windows10
​ Python: 3.7.3

 最初はpip install opencv-pythonで導入仕様としていたが、どうやら最新OpenCVのバージョンとPythonのバージョンがあっていない?インストールは成功するが、パッケージを読み込んでくれなかった。

解決方法

pip install opencv_python-4.X.X-cpXX-win_amd64.whlでインストール

1). https://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv から、自分のOSとPythonのバージョンにあった.whlファイルを選択する。
​ cp37 : Python 3.7.X
​ win_amd64: 64bit Windows

2). ダウンロードしたディレクトリに移動し、ターミナルで以下のコマンドを実行

pip install opencv_python-4.1.1-cp37-cp37m-win_amd64.whl

3). 同様にnumpyもインストール

pip install numpy

この方法で問題なくOpenCVを使うことができるようになりました。

補足
numpyがすでに入っていて、cv2をインポート時にImportError: numpy.core.multiarray failed to imporエラーが出た場合は最新版にアップグレードする(参考)。

1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3