!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/')
:来自 < Installing RDKit in Google Colab 的
上面的代码是 stackoverflow 中另一篇关于在 Google Colab 中导入“rdkit”的文章的解决方案之一,但它对我不起作用并显示此错误消息:
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)
有人知道如何解决这个 ImportError: `GLIBCXX_3.4.26' not found 问题吗? 我真诚地需要帮助!非常感谢!
最佳答案
您链接的答案现在有点过时了。在 Colab 上安装最新版本的 RDKit (2020.09.3) 似乎也存在问题。安装旧版本 (2020.09.2) 似乎可以解决问题:
%%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
其次是:
import sys
sys.path.append('/usr/local/lib/python3.7/site-packages/')
from rdkit import Chem
如果您必须安装最新版本 (2020.09.3),我已经通过在 bash 单元格中添加几行找到了一个解决方法:
%%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
为了让它工作,运行时也需要重新启动,我只是在 rdkit 导入周围添加一个 try/except 来自动重新启动运行时:
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 链接:https://colab.research.google.com/drive/1vhsLgzA7A_INMcbU-hG6go4M6axvbUpi?usp=sharing
第二个解决方案的 Colab 链接:https://colab.research.google.com/drive/1Ix0oyUU4cA1b2rD9JfkMhy8M2z5Y_vTL?usp=sharing
关于importerror - 这些天如何在google colab中导入rdkit?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65487584/