Closed MichelML closed 2 years ago
Closing here.
For the record, the issue was due to the relocation of a conda env using conda-pack
. RDKit seems to hard code the absolute paths of the rdkit config folder and so during the relocation the config paths does not point to the correct folder anymore explaining the import module error.
There is no real good solution for this on the rdkit side currently since using relative paths might also causes issues on non-standard systems.
Hello @MichelML @hadim, did it work for you to just import RDKit before datamol? Did not for me..
Any recommended workaround? Should we go back to an older RDKit?
With datamol 0.7.3 and rdkit 2022.03.2, I'm getting:
import rdkit.Chem as Chem
from rdkit.Chem import AllChem
...
import datamol as dm
File ~/opt/anaconda3/envs/my-rdkit-env/lib/python3.10/site-packages/datamol/__init__.py:74, in <module>
72 from . import actions
73 from . import molar
---> 74 from . import descriptors
75 from . import predictors
77 from .convert import to_smiles
File ~/opt/anaconda3/envs/my-rdkit-env/lib/python3.10/site-packages/datamol/descriptors/__init__.py:1, in <module>
----> 1 from .descriptors import mw
2 from .descriptors import fsp3
3 from .descriptors import n_hba
File ~/opt/anaconda3/envs/my-rdkit-env/lib/python3.10/site-packages/datamol/descriptors/descriptors.py:15, in <module>
12 from rdkit.Chem import Crippen
14 sys.path.append(os.path.join(RDConfig.RDContribDir, "SA_Score"))
---> 15 import sascorer # type:ignore
17 from .. import Mol
18 from ..convert import from_smarts
ModuleNotFoundError: No module named 'sascorer'
Thank you!
What OS are you using?
Mac 11.5.1 Thanks for helping with this!
On Fri, 13 May 2022, 12:30 Hadrien Mary, @.***> wrote:
What OS are you using?
— Reply to this email directly, view it on GitHub https://github.com/datamol-org/datamol/issues/83#issuecomment-1125896877, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGBKIPKTFDOSSVTTGSKNWWTVJYVMLANCNFSM5OY4JBPQ . You are receiving this because you commented.Message ID: @.***>
I can't reproduce on Linux. I'll check if I can get access to an OSX machine.
@adelenelai anyway we can see your conda env file? do you use pypi or conda to install rdkit and datamol?
@mercuryseries @maclandrol I think you guys have a Mac if you want to test this quickly.
For rdkit and datamol I used conda. datamol is installed within my rdkit env.
Thanks a lot.
(my-rdkit-env) adelene.lai$ conda list
# packages in environment at .../my-rdkit-env:
#
# Name Version Build Channel
appdirs 1.4.4 pyh9f0ad1d_0 conda-forge
appnope 0.1.2 py310hecd8cb5_1001
argon2-cffi 21.3.0 pyhd3eb1b0_0
argon2-cffi-bindings 21.2.0 py310hca72f7f_0
asttokens 2.0.5 pyhd3eb1b0_0
attrs 21.4.0 pyhd3eb1b0_0
backcall 0.2.0 pyhd3eb1b0_0
beautifulsoup4 4.11.1 py310hecd8cb5_0
bleach 4.1.0 pyhd3eb1b0_0
boost 1.74.0 py310h509978a_5 conda-forge
boost-cpp 1.74.0 h8b082ac_8 conda-forge
brotli 1.0.9 h5eb16cf_7 conda-forge
brotli-bin 1.0.9 h5eb16cf_7 conda-forge
bzip2 1.0.8 h0d85af4_4 conda-forge
ca-certificates 2021.10.8 h033912b_0 conda-forge
cairo 1.16.0 h1680b09_1011 conda-forge
certifi 2021.10.8 py310h2ec42d9_2 conda-forge
cffi 1.15.0 py310hc55c11b_1
colorama 0.4.4 pyh9f0ad1d_0 conda-forge
cycler 0.11.0 pyhd8ed1ab_0 conda-forge
datamol 0.7.3 pyhd8ed1ab_0 conda-forge
debugpy 1.5.1 py310he9d5cce_0
decorator 5.1.1 pyhd3eb1b0_0
defusedxml 0.7.1 pyhd3eb1b0_0
entrypoints 0.4 py310hecd8cb5_0
executing 0.8.3 pyhd3eb1b0_0
expat 2.4.8 h96cf925_0 conda-forge
font-ttf-dejavu-sans-mono 2.37 hab24e00_0 conda-forge
font-ttf-inconsolata 3.000 h77eed37_0 conda-forge
font-ttf-source-code-pro 2.038 h77eed37_0 conda-forge
font-ttf-ubuntu 0.83 hab24e00_0 conda-forge
fontconfig 2.14.0 h676cef8_0 conda-forge
fonts-conda-ecosystem 1 0 conda-forge
fonts-conda-forge 1 0 conda-forge
fonttools 4.33.3 py310h6c45266_0 conda-forge
freetype 2.10.4 h4cff582_1 conda-forge
fsspec 2022.3.0 pyhd8ed1ab_0 conda-forge
gettext 0.19.8.1 hd1a6beb_1008 conda-forge
giflib 5.2.1 hbcb3906_2 conda-forge
greenlet 1.1.2 py310h9d931ec_2 conda-forge
icu 70.1 h96cf925_0 conda-forge
ipykernel 6.9.1 py310hecd8cb5_0
ipython 8.3.0 py310hecd8cb5_0
ipython_genutils 0.2.0 pyhd3eb1b0_1
ipywidgets 7.7.0 pypi_0 pypi
jbig 2.1 h0d85af4_2003 conda-forge
jedi 0.18.1 py310hecd8cb5_1
jinja2 3.0.3 pyhd3eb1b0_0
joblib 1.1.0 pyhd8ed1ab_0 conda-forge
jpeg 9e h5eb16cf_1 conda-forge
jsonschema 4.4.0 py310hecd8cb5_0
jupyter_client 7.2.2 py310hecd8cb5_0
jupyter_core 4.10.0 py310hecd8cb5_0
jupyterlab-widgets 1.1.0 pypi_0 pypi
jupyterlab_pygments 0.1.2 py_0
kiwisolver 1.4.2 py310h6be76da_1 conda-forge
lcms2 2.12 h577c468_0 conda-forge
lerc 3.0 he49afe7_0 conda-forge
libblas 3.9.0 14_osx64_openblas conda-forge
libbrotlicommon 1.0.9 h5eb16cf_7 conda-forge
libbrotlidec 1.0.9 h5eb16cf_7 conda-forge
libbrotlienc 1.0.9 h5eb16cf_7 conda-forge
libcblas 3.9.0 14_osx64_openblas conda-forge
libcxx 13.0.1 hc203e6f_0 conda-forge
libdeflate 1.10 h0d85af4_0 conda-forge
libffi 3.4.2 h0d85af4_5 conda-forge
libgfortran 5.0.0 9_3_0_h6c81a4c_23 conda-forge
libgfortran5 9.3.0 h6c81a4c_23 conda-forge
libglib 2.70.2 hf1fb8c0_4 conda-forge
libiconv 1.16 haf1e3a3_0 conda-forge
liblapack 3.9.0 14_osx64_openblas conda-forge
libopenblas 0.3.20 openmp_hb3cd9ec_0 conda-forge
libpng 1.6.37 h7cec526_2 conda-forge
libsodium 1.0.18 h1de35cc_0
libtiff 4.3.0 h17f2ce3_3 conda-forge
libwebp 1.2.2 h28dabe5_0 conda-forge
libwebp-base 1.2.2 h0d85af4_1 conda-forge
libxcb 1.13 h0d85af4_1004 conda-forge
libzlib 1.2.11 h6c3fc93_1014 conda-forge
llvm-openmp 14.0.3 ha654fa7_0 conda-forge
loguru 0.6.0 py310h2ec42d9_1 conda-forge
lz4-c 1.9.3 he49afe7_1 conda-forge
markupsafe 2.0.1 py310hca72f7f_0
matplotlib-base 3.5.2 py310h4510841_0 conda-forge
matplotlib-inline 0.1.2 pyhd3eb1b0_2
mistune 0.8.4 py310hca72f7f_1000
mols2grid 0.2.2 pypi_0 pypi
munkres 1.1.4 pyh9f0ad1d_0 conda-forge
nb_conda_kernels 2.3.1 py310hecd8cb5_0
nbclient 0.5.13 py310hecd8cb5_0
nbconvert 6.4.4 py310hecd8cb5_0
nbformat 5.3.0 py310hecd8cb5_0
ncurses 6.3 h96cf925_1 conda-forge
nest-asyncio 1.5.5 py310hecd8cb5_0
notebook 6.4.11 py310hecd8cb5_0
numpy 1.22.3 py310he1f95b8_2 conda-forge
openjpeg 2.4.0 h6e7aa92_1 conda-forge
openssl 3.0.3 hfe4f2af_0 conda-forge
packaging 21.3 pyhd8ed1ab_0 conda-forge
pandas 1.4.2 py310h514ec25_1 conda-forge
pandocfilters 1.5.0 pyhd3eb1b0_0
parso 0.8.3 pyhd3eb1b0_0
pcre 8.45 he49afe7_0 conda-forge
pexpect 4.8.0 pyhd3eb1b0_3
pickleshare 0.7.5 pyhd3eb1b0_1003
pillow 9.1.0 py310h382dc3b_2 conda-forge
pip 22.0.4 pyhd8ed1ab_0 conda-forge
pixman 0.40.0 hbcb3906_0 conda-forge
prometheus_client 0.13.1 pyhd3eb1b0_0
prompt-toolkit 3.0.20 pyhd3eb1b0_0
pthread-stubs 0.4 hc929b4f_1001 conda-forge
ptyprocess 0.7.0 pyhd3eb1b0_2
pure_eval 0.2.2 pyhd3eb1b0_0
pycairo 1.21.0 py310h5138a19_1 conda-forge
pycparser 2.21 pyhd3eb1b0_0
pygments 2.11.2 pyhd3eb1b0_0
pyparsing 3.0.8 pyhd8ed1ab_0 conda-forge
pyrsistent 0.18.0 py310hca72f7f_0
python 3.10.4 h1cc4136_0_cpython conda-forge
python-dateutil 2.8.2 pyhd8ed1ab_0 conda-forge
python-fastjsonschema 2.15.1 pyhd3eb1b0_0
python_abi 3.10 2_cp310 conda-forge
pytz 2022.1 pyhd8ed1ab_0 conda-forge
pyzmq 22.3.0 py310he9d5cce_2
rdkit 2022.03.2 py310haadc31d_0 conda-forge
rdkit-pypi 2022.3.2.1 pypi_0 pypi
readline 8.1 h05e3726_0 conda-forge
reportlab 3.5.68 py310h3301372_1 conda-forge
scikit-learn 1.1.0 py310hfc06b38_0 conda-forge
scipy 1.8.0 py310h47774c9_1 conda-forge
selfies 2.0.0 pyhd8ed1ab_0 conda-forge
send2trash 1.8.0 pyhd3eb1b0_1
setuptools 62.1.0 py310h2ec42d9_0 conda-forge
six 1.16.0 pyh6c4a22f_0 conda-forge
soupsieve 2.3.1 pyhd3eb1b0_0
sqlalchemy 1.4.36 py310h6c45266_0 conda-forge
sqlite 3.38.4 hd9f0692_0 conda-forge
stack_data 0.2.0 pyhd3eb1b0_0
terminado 0.13.1 py310hecd8cb5_0
testpath 0.5.0 pyhd3eb1b0_0
threadpoolctl 3.1.0 pyh8a188c0_0 conda-forge
tk 8.6.12 h5dbffcc_0 conda-forge
tornado 6.1 py310hca72f7f_0
tqdm 4.64.0 pyhd8ed1ab_0 conda-forge
traitlets 5.1.1 pyhd3eb1b0_0
typing-extensions 4.1.1 hd3eb1b0_0
typing_extensions 4.1.1 pyh06a4308_0
tzdata 2022a h191b570_0 conda-forge
unicodedata2 14.0.0 py310h1961e1f_1 conda-forge
wcwidth 0.2.5 pyhd3eb1b0_0
webencodings 0.5.1 py310hecd8cb5_1
wheel 0.37.1 pyhd8ed1ab_0 conda-forge
widgetsnbextension 3.6.0 pypi_0 pypi
xorg-libxau 1.0.9 h35c211d_0 conda-forge
xorg-libxdmcp 1.1.3 h35c211d_0 conda-forge
xz 5.2.5 haf1e3a3_1 conda-forge
zeromq 4.3.4 h23ab428_0
zlib 1.2.11 h6c3fc93_1014 conda-forge
zstd 1.5.2 h582d3a0_0 conda-forge
Will test this morning, but my first guess is rdkit pypi not packaging the contrib
(including sasscorer
) module, since it's not part of the 'package' itself.
Can you print
from rdkit.Chem import RDConfig
In [3]: RDConfig.RDContribDir
Out[3]: '/Users/manu/.miniconda/envs/testenv/share/RDKit/Contrib'
Then check whether you see SA_Score
in the RDKIT Contrib folder ?
ls /Users/manu/.miniconda/envs/testenv/share/RDKit/Contrib
@adelenelai I see you have two versions of rdkit in your env:
rdkit 2022.03.2 py310haadc31d_0 conda-forge
rdkit-pypi 2022.3.2.1 pypi_0 pypi
I would try to remove rdkit-pypi from your env as a first attempt (and try what @maclandrol suggested)
@adelenelai Confirmed. The rdkit from pypi
does not package the 'Contrib' module, thus it cannot be imported.
In your case, the interpreter is picking up the rdkit-pypi
over the one from conda-forge. This happens likely because you pip install 'rdkit-pypi'
AFTER installing datamol.
I am not sure a simple pip uninstall 'rdkit-pypi'
would work, so instead you can either create a new env, or run the following:
pip uninstall 'rdkit-pypi'
mamba install datamol -c conda-forge --force-reinstall
mamba install rdkit -c conda-forge --force-reinstall
As a side note, remember that if you install datamol
from conda-forge, you don't need to install rdkit
anymore.
@hadim , we should remove anything that links to contrib
from the __init__
for cases like this.
Hello @MichelML and @maclandrol
I did pip uninstall rdkit-pypi
to leave rdkit
remaining in the env as you advised.
But...things started to break and I couldn't even do import rdkit.Chem.rdchem as rdchem
any more D:
So...I did a fresh install of rdkit in a new env, then conda install -c conda-forge datamol
.
After that, importing datamol
was no problem :)
Thanks a lot for your speedy help
@hadim , we should remove anything that links to
contrib
from the__init__
for cases like this.
Yes, we should catch the error and make it silent (or simply a warning).
Thank you @adelenelai for the report!
Fixed in >=0.7.4 now on pypi and soon on conda (a few hours).
Posting so it's logged somewhere.
Is this a new dependency for datamol? Disclaimer, I didn't update datamol in my project (lambdomics) since a couple months (I was at 0.5 before upgrading).
sascorer
seems to have appear in commit 8576d4b with the descriptors module, and this module is imported by default when usingimport datamol as dm
.sascorer seems to be a module coming from RDKit but I'm not sure. Is it just a matter of making sure to import RDKit before datamol if you use both in your project?