LoginSignup
97
99

More than 5 years have passed since last update.

condaが探すリポジトリ先を変更する方法(conda-forgeの追加)

Last updated at Posted at 2018-05-26

Pythonのパッケージをインストールする際、pipやcondaを使われる方が多いと思います。

簡単におさらいすると、
pipはPyPI(Python Package Index) で配布されているパッケージをインストールします。

condaはデフォルトでは次の場所からダウンロードされます。

defaults(デフォルトレポジトリ):
https://repo.continuum.io/pkgs/

しかし、インストールしたいパッケージがこれらの中には存在しない場合があります。
そのような場合、condaが探すリポジトリ先を変更することでインストールできるかもしれません。

例えば、LIMEというパッケージが存在しますが、
これはpipやデフォルトのcondaではインストールすることができません。(私の環境だと。)

しかし、condaが探すリポジトリ先にconda-forgeを加えることでLIMEがインストールが可能になります。
conda-forgeはgithub上のコミュニティ主体のパッケージコレクションで、LIME以外にもたくさんのパッケージを公開しており、condaのdefaultsでは見つからないパッケージをダウンロードすることが可能です。
参考:conda-forge
本記事ではcondaのインストール先にconda-forgeを加える方法を記載します。

LIMEとは

本記事の趣旨からかなりずれるのですが、LIMEについて少しだけ紹介させてください。
LIMEは、Explainable AIの1つで、ある予測モデルが何故そのような予測をしたのかを可視化できるモデルです。
1.png
AI業界ではモデルの説明性のブラックボックス化が囁かれておりますが、LIMEはそれを解決する手法の1つです。
詳細は以下の記事をご参考ください。
<作成中>

LIME論文
"Why Should I Trust You?": Explaining the Predictions of Any Classifier

condaのダウンロード先の変更方法

本題に入ります。
LIMEというパッケージはcondaのデフォルトのインストール先ではインストールできません。
インストールしようとすると、以下のようになります。

$conda install lime
Solving environment: failed

PackagesNotFoundError: The following packages are not available from current channels:

  - lime

Current channels:

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

そこで、condaが探すリポジトリ先を確認します。

$conda config --get channels
--add channels 'defaults'   # lowest priority

defaultsを探しにいっていることがわかります。

そこで、探す先にconda-forgeを追加します。

$conda config --append channels conda-forge

conda-forgeが追加されたことを確認します。

$conda config --get channels
--add channels 'conda-forge'   # lowest priority
--add channels 'defaults'   # highest priority

再度LIMEをインストールします。

$conda install lime
Solving environment: done

## Package Plan ##

  environment location: C:xxxx/xxxx/xxxx

  added / updated specs:
    - lime


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    libsodium-1.0.16           |           vc14_0         582 KB  conda-forge
    zeromq-4.2.5               |           vc14_1         9.6 MB  conda-forge
    lime-0.1.1.30              |           py36_0         249 KB  conda-forge
    ------------------------------------------------------------
                                           Total:        10.4 MB

The following NEW packages will be INSTALLED:

    lime:      0.1.1.30-py36_0   conda-forge

The following packages will be UPDATED:

    libsodium: 1.0.16-h9d3ae62_0             --> 1.0.16-vc14_0 conda-forge [vc14]
    zeromq:    4.2.5-hc6251cf_0              --> 4.2.5-vc14_1  conda-forge [vc14]

Proceed ([y]/n)? y


Downloading and Extracting Packages
libsodium 1.0.16: ############################################################################################# | 100%
zeromq 4.2.5: ################################################################################################# | 100%
lime 0.1.1.30: ################################################################################################ | 100%
Preparing transaction: done
Verifying transaction: done

conda-forgeからLIMEを探してきてくれました。

このように、condaやpipでは見つからないパッケージを探すときは、conda-forgeを使ってみてください!

97
99
2

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
97
99