如何在Colab中永久安装模块(RDKIT)

时间:2020-08-04 10:16:39

标签: google-colaboratory rdkit

如何在Colab中永久安装库?

我遵循了该主题接受的答案

How do I install a library permanently in Colab?

# first install gcsfuse
%%capture
!echo "deb http://packages.cloud.google.com/apt gcsfuse-bionic main" > /etc/apt/sources.list.d/gcsfuse.list
!curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
!apt update
!apt install gcsfuse

%%writefile /key.json
{
  "type": "service_account",
  "project_id": "kora-id",
  "private_key_id": "xxxxxxx",
  "private_key": "-----BEGIN PRIVATE KEY-----\nxxxxxxx==\n-----END PRIVATE KEY-----\n",
  "client_email": "colab-7@kora-id.iam.gserviceaccount.com",
  "client_id": "100380920993833371482",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://oauth2.googleapis.com/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/colab-7%40kora-id.iam.gserviceaccount.com"
}

%env GOOGLE_APPLICATION_CREDENTIALS=/key.json


!mkdir /content/my-bucket
!gcsfuse my-bucket /content/my-bucket

import sys
nb_path = '/content/my-bucket'
sys.path.insert(0, nb_path)
# Do this just once
!pip install --target=$nb_path jdc

我遵循https://www.youtube.com/watch?v=ERvUf_lNopo

的RDKIT安装
# Install RDKit. Takes 2-3 minutes
!wget -c https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
!chmod +x Miniconda3-latest-Linux-x86_64.sh
!time bash ./Miniconda3-latest-Linux-x86_64.sh -b -f -p /usr/local
!time conda install -q -y -c anaconda python=3.7
!time conda install -q -y -c conda-forge rdkit

1 个答案:

答案 0 :(得分:1)

您可以使用此代码,这避免了conda并可以在6秒内安装rdkit

url = 'https://anaconda.org/rdkit/rdkit/2018.09.1.0/download/linux-64/rdkit-2018.09.1.0-py36h71b666b_1.tar.bz2'
!curl -L $url | tar xj lib
!mv lib/python3.6/site-packages/rdkit /usr/local/lib/python3.6/dist-packages/
x86 = '/usr/lib/x86_64-linux-gnu'
!mv lib/*.so.* $x86/
!ln -s $x86/libboost_python3-py36.so.1.65.1 $x86/libboost_python3.so.1.65.1

更新:我制作了一个自定义的tarball,我们可以将其解压缩。仅需1.7秒即可安装

!curl -L bit.ly/rdkit-colab | tar xz -C /

您还可以使用我的kora库。

!pip install kora
import kora.install.rdkit