a_sue’s diary

a_sue の日記 はてなブログ版

Anaconda で lifelines をインストールできない場合

Jupyter Notebook でポチポチ入力しながら読んでる続き。

a-sue.hatenablog.com

13章で lifelines ライブラリを使ってる。
ソースのコメントで

# pip install lifelines

と書いてあって、実際ライブラリが見つからないエラーが出る。

import pandas as pd
from lifelines import KaplanMeierFitter
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-26-83ad2ac062b6> in <module>()
      1 import pandas as pd
----> 2 from lifelines import KaplanMeierFitter

ModuleNotFoundError: No module named 'lifelines'

いつものパターンね、といつもの通りにやると、、、

C:\WINDOWS\system32>conda install --prefix "C:\Program Files\Anaconda3" lifelines
Collecting package metadata: done
Solving environment: failed

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

  - lifelines

Current channels:

  - https://conda.anaconda.org/anaconda-fusion/win-64
  - https://conda.anaconda.org/anaconda-fusion/noarch
  - https://repo.anaconda.com/pkgs/main/win-64
  - https://repo.anaconda.com/pkgs/main/noarch
  - https://repo.anaconda.com/pkgs/free/win-64
  - https://repo.anaconda.com/pkgs/free/noarch
  - https://repo.anaconda.com/pkgs/r/win-64
  - https://repo.anaconda.com/pkgs/r/noarch
  - https://repo.anaconda.com/pkgs/msys2/win-64
  - https://repo.anaconda.com/pkgs/msys2/noarch

To search for alternate channels that may provide the conda package you're
looking for, navigate to

    https://anaconda.org

and use the search bar at the top of the page.



C:\WINDOWS\system32>

あら?

というわけで、conda lifelinesググるとここがヒット

anaconda.org

なるほど、こうするのね

conda install -c conda-forge --prefix "C:\Program Files\Anaconda3" lifelines

C:\WINDOWS\system32>conda install -c conda-forge  --prefix "C:\Program Files\Anaconda3" lifelines
Collecting package metadata: done
Solving environment: done

## Package Plan ##

  environment location: C:\Program Files\Anaconda3

  added / updated specs:
    - lifelines


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    autograd-1.2               |             py_1          33 KB  conda-forge
    ca-certificates-2018.11.29 |       ha4d7672_0         179 KB  conda-forge
    certifi-2018.11.29         |        py36_1000         145 KB  conda-forge
    conda-4.6.7                |           py36_0         891 KB  conda-forge
    future-0.17.1              |        py36_1000         697 KB  conda-forge
    lifelines-0.19.4           |             py_0         199 KB  conda-forge
    openssl-1.1.1b             |       hfa6e2cd_0         4.7 MB  conda-forge
    ------------------------------------------------------------
                                           Total:         6.8 MB

The following NEW packages will be INSTALLED:

  autograd           conda-forge/noarch::autograd-1.2-py_1
  future             conda-forge/win-64::future-0.17.1-py36_1000
  lifelines          conda-forge/noarch::lifelines-0.19.4-py_0

The following packages will be UPDATED:

  certifi              pkgs/main::certifi-2018.11.29-py36_0 --> conda-forge::certifi-2018.11.29-py36_1000

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

  ca-certificates    pkgs/main::ca-certificates-2019.1.23-0 --> conda-forge::ca-certificates-2018.11.29-ha4d7672_0
  conda                                           pkgs/main --> conda-forge
  openssl              pkgs/main::openssl-1.1.1b-he774522_0 --> conda-forge::openssl-1.1.1b-hfa6e2cd_0


Proceed ([y]/n)? y


Downloading and Extracting Packages
conda-4.6.7          | 891 KB    | ############################################################################ | 100%
openssl-1.1.1b       | 4.7 MB    | ############################################################################ | 100%
autograd-1.2         | 33 KB     | ############################################################################ | 100%
ca-certificates-2018 | 179 KB    | ############################################################################ | 100%
certifi-2018.11.29   | 145 KB    | ############################################################################ | 100%
lifelines-0.19.4     | 199 KB    | ############################################################################ | 100%
future-0.17.1        | 697 KB    | ############################################################################ | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

C:\WINDOWS\system32>

よし、これで行けた。