3
!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/')

: The code from <Installing RDKit in Google Colab>

The code above is one of the solutions from another article in stackoverflow on importing 'rdkit' in Google Colab, but it didn't work for me with this error message:

from rdkit import Chem

ImportError: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by /usr/local/lib/python3.7/site-packages/rdkit/DataStructs/cDataStructs.so)

Does anybody know how to solve this ImportError: `GLIBCXX_3.4.26' not found problem? I sincerely need help! Big thx!

Seungwoo Ryu
  • 121
  • 2
  • 8

3 Answers3

3

The answer you linked is a little outdated now. Seems like there is also an issue with installing the latest build of the RDKit (2020.09.3) on Colab. Installing the older version (2020.09.2) seems to solve the issue:

%%bash
wget -c https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
chmod +x Miniconda3-latest-Linux-x86_64.sh
./Miniconda3-latest-Linux-x86_64.sh -b -f -p /usr/local
conda config --set always_yes yes --set changeps1 no
conda install -q -y -c conda-forge python=3.7
conda install -q -y -c conda-forge rdkit==2020.09.2 

Followed by:

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

If you must install the latest build (2020.09.3), I have found a workaround by adding a few lines to the bash cell:

%%bash
add-apt-repository ppa:ubuntu-toolchain-r/test
apt-get update --fix-missing
apt-get dist-upgrade
wget -c https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
chmod +x Miniconda3-latest-Linux-x86_64.sh
./Miniconda3-latest-Linux-x86_64.sh -b -f -p /usr/local
conda config --set always_yes yes --set changeps1 no
conda install -q -y -c conda-forge python=3.7
conda install -q -y -c conda-forge rdkit

To make this work the runtime also will need to be restarted, I just add a try/except around the rdkit import to restart the runtime automatically:

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

try:
  from rdkit import Chem
  from rdkit.Chem.Draw import IPythonConsole
except ImportError:
  print('Stopping RUNTIME. Colaboratory will restart automatically. Please run cell again.')
  exit()

Colab link for the first solution: https://colab.research.google.com/drive/1vhsLgzA7A_INMcbU-hG6go4M6axvbUpi?usp=sharing

Colab link for the second solution: https://colab.research.google.com/drive/1Ix0oyUU4cA1b2rD9JfkMhy8M2z5Y_vTL?usp=sharing

Dharman
  • 30,962
  • 25
  • 85
  • 135
Oliver Scott
  • 1,673
  • 8
  • 17
  • I don't know why my comment is deleted! So much thx for solving my problem, sincerely! – Seungwoo Ryu Dec 30 '20 at 07:25
  • @Oliver would you mind to check my question (https://stackoverflow.com/questions/67878866/valueerror-bitvects-must-be-same-length-rdkit?noredirect=1#comment119985854_67878866). I would be grateful. – Opps_0 Jun 08 '21 at 18:58
1

I think the best way of doing that is to use condacolab by Jaime Rodríguez-Guerra and Alex Malins.
https://github.com/conda-incubator/condacolab

!pip install -q condacolab
import condacolab
condacolab.install()
then
import condacolab
condacolab.check()

Jae Mun Choi
  • 129
  • 1
  • 4
0

Well one simple trick is to install deepchem and it comes with rdkit

!pip install deepchem

from rdkit import Chem

antokhio
  • 1,497
  • 2
  • 11
  • 16
D_M
  • 1
  • 1
  • 4