Install conda package from Google Datalab

2019-09-19 08:25发布

I'm looking to use the ospc taxcalc package in a Google Datalab notebook. This package must be installed via conda.

Datalab doesn't have conda by default, so this method (from https://stackoverflow.com/a/33176085/1840471) fails:

%%bash
conda install -c ospc taxcalc

Installing via pip also doesn't work:

%%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.

Following that URL, I tried this:

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

wget works, but the bash command to install just kept in "Running..." state for seeming perpetuity.

This seems to be due to the conda installer prompting for several Enter keystrokes to review the license, and then for a yes indicating acceptance of the license terms. So conda's silent mode installation looked promising:

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

This produced the following warning:

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

And doesn't make available the conda command:

%%bash
conda install -c ospc taxcalc

bash: line 1: conda: command not found

2条回答
萌系小妹纸
2楼-- · 2019-09-19 08:59

There is a pending github issue tracking this work - https://github.com/googledatalab/datalab/issues/1376

I believe we will need to install conda and use that for python, pip and all other python packages, and in the interim it may not be possible to mix the two python environments. However someone with more experience with conda might know otherwise.

查看更多
干净又极端
3楼-- · 2019-09-19 09:03

As of the 2018-02-21 release, Datalab supports Conda and kernels are each in their own Conda environment.

查看更多
登录 后发表回答