从 Google Datalab 安装 conda 包

Install conda package from Google Datalab

我想在 Google Datalab 笔记本中使用 ospc taxcalc 包。此软件包必须通过 conda 安装。

Datalab 默认没有conda,所以这个方法(来自)失败了:

%%bash
conda install -c ospc taxcalc

通过 pip 安装也不起作用:

%%bash
pip install conda
conda install -c ospc taxcalc

ERROR: The install method you used for conda--probably either pip install conda or easy_install conda--is not compatible with using conda as an application. If your intention is to install conda as a standalone application, currently supported install methods include the Anaconda installer and the miniconda installer. You can download the miniconda installer from https://conda.io/miniconda.html.

在 URL 之后,我尝试了这个:

%%bash
wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh
bash Miniconda2-latest-Linux-x86_64.sh

wget 有效,但是要安装的 bash 命令似乎永远保持在 "Running..." 状态。

这似乎是由于 conda 安装程序提示多次 Enter 击键以查看许可,然后 yes 提示接受许可条款。所以 conda 的 silent mode installation 看起来很有希望:

%%bash
bash Miniconda2-latest-Linux-x86_64.sh -u -b -p $HOME/miniconda

这产生了以下警告:

WARNING: You currently have a PYTHONPATH environment variable set. This may cause unexpected behavior when running the Python interpreter in Miniconda2. For best results, please verify that your PYTHONPATH only points to directories of packages that are compatible with the Python interpreter in Miniconda2: /content/miniconda

并且不提供 conda 命令:

%%bash
conda install -c ospc taxcalc

bash: line 1: conda: command not found

有一个未决的 github 问题跟踪这项工作 - https://github.com/googledatalab/datalab/issues/1376

我相信我们需要安装 conda 并将其用于 python、pip 和所有其他 python 包,在此期间可能无法混合使用这两个 python 环境。然而,对 conda 有更多经验的人可能会有所不同。

2018-02-21 release 开始,Datalab 支持 Conda,每个内核都在自己的 Conda 环境中。