pythongoogle-colaboratoryrdkit

Installing RDKit in Google Colab


I cannot figure out how to fix the following issue. Up until today I was using the following code snippet for installing RDKit in Google Colab:

!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 conda-forge rdkit

import sys
sys.path.append('/usr/local/lib/python3.7/site-packages/')

However, today I started to get the following error:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-2-d24c24e2d1f9> in <module>()
----> 1 from rdkit import Chem
      2 import networkx as nx

ModuleNotFoundError: No module named 'rdkit'

I've tried using the full Anaconda distribution instead of Miniconda, as well as changing the python version to 3.6 and 3.8 but nothing seems to work.


Solution

  • I think you need to specify python 3.7 when you install Miniconda (the current rdkit build supports python 3.7), the latest Miniconda version is py3.8:

    !wget -c https://repo.continuum.io/miniconda/Miniconda3-py37_4.8.3-Linux-x86_64.sh
    !chmod +x Miniconda3-py37_4.8.3-Linux-x86_64.sh
    !time bash ./Miniconda3-py37_4.8.3-Linux-x86_64.sh -b -f -p /usr/local
    !time conda install -q -y -c conda-forge rdkit
    
    import sys
    sys.path.append('/usr/local/lib/python3.7/site-packages/')
    

    https://colab.research.google.com/drive/1MAZyv3O4-TrI8c1MD4JVmwExDquaprRT?usp=sharing