msdd’s blog

deep learning勉強中。プログラム関連のこと書きます。

pythonライブラリmmcvのインストールエラーの解決法

はじめに

pythonライブラリのmmcvをインストールしようとした時にエラーが出たので、 それの記録しておく。

出てきたエラー

building 'mmcv._ext' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio":https://visualstudio.microsoft.com/downloads/

MMCV

github url: https://github.com/open-mmlab/mmcv

MMCVは、コンピュータビジョンの研究のためのpythonのライブラリである。

下のような機能がある。

  • ユニバーサルなIO API
  • 画像処理
  • 動画処理
  • 画像とアノテーションの視覚化
  • Utility(プログレスバー、タイマーなど)
  • さまざまなCNN

MMCVを使うには、pythonのバージョンは、3.6以上が必要とある。 しかし、windows10のマシンで、anacondaを使ってインストールしようとするとエラーが出た。

エラー解決法

mmcvをインストールしてエラーが出る

仮想環境を作って試す。 mmcv_installationという名前で、pythonのバージョンは3.8の仮想環境を作った。 p

conda create -n mmcv_installation python=3.8

仮想環境立ち上げる。

conda activate mmcv_installation

mmcvをインストールするコマンドをうつ。

pip install mmcv

インストールが始まるが、途中でエラーが出て止まってしまった。

ERROR: Command errored out with exit status 1:

赤文字でバーとエラーが出てくる。

f:id:msdd:20200427135545p:plain

解決法

下側のエラーに下のように書かれているのが出て来る。 どうやらVisual C++ 14.0がいるらしい。リンク付で表示されているので、 リンクへ飛んでVisual C++ 14.0をインストールしに行く。

building 'mmcv._ext' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/

Visual C++ 14.0をダウンロードしにいく。 ダウンロードページのすべてのダウンロードの部分に、 ある、Visual Studio 2019のツールのアコーディオンを開いて、 Build Tools for Visual Studio 2019をダウンロードする。

f:id:msdd:20200427135557p:plain

ダウンロード後に、インストールする。 続行を押す。

f:id:msdd:20200427135610p:plain

左上のc++ build toolsにチェックを入れてインストールする。

f:id:msdd:20200427135621p:plain

インストールが終わるまで待つ。 終わると、再起動が必要とでるので、再起動する。

f:id:msdd:20200427135633p:plain

再起動後に、再びインストールする。

conda activate mmcv_installation
pip install mmcv

エラーなくインストールできた。

Successfully built mmcv
Installing collected packages: mmcv
Successfully installed mmcv-0.4.4

まとめ

mmcvのインストール時にエラーが出た。 エラー内容を見てみると、Visual C++ 14.0が必要みたいだった。 Microsoftのダウンロードページからダウンロード、インストールした。 結果、エラーなくmmcvをインストールできた。