ci-lab-cz / easydock

BSD 3-Clause "New" or "Revised" License
35 stars 12 forks source link

DLL load failed while importing rdmolfiles: The specified procedure could not be found #16

Closed BuiQuocDung1991 closed 7 months ago

BuiQuocDung1991 commented 9 months ago

Hi everyone, I install easydock with the snippet of code in conda:

conda create -n easydock python=3.9 -y
conda activate easydock
conda install -c conda-forge numpy=1.20 rdkit scipy dask distributed -y
pip install meeko
pip install easydock
conda install ipykernel -y

I run your python example, and the error appears

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
[d:\OneDrive](file:///D:/OneDrive) - UMP\test\test.ipynb Cell 1 line 1
----> [1](vscode-notebook-cell:/d%3A/OneDrive%20-%20UMP/test/test.ipynb#W0sZmlsZQ%3D%3D?line=0) from easydock.run_dock import docking
      [2](vscode-notebook-cell:/d%3A/OneDrive%20-%20UMP/test/test.ipynb#W0sZmlsZQ%3D%3D?line=1) from easydock.vina_dock import mol_dock
      [3](vscode-notebook-cell:/d%3A/OneDrive%20-%20UMP/test/test.ipynb#W0sZmlsZQ%3D%3D?line=2) # from easydock.gnina_dock import mol_dock  # <- enable gnina docking

File [e:\Software\Anaconda3\envs\easydock\lib\site-packages\easydock\run_dock.py:10](file:///E:/Software/Anaconda3/envs/easydock/lib/site-packages/easydock/run_dock.py:10)
      7 from functools import partial
      8 from multiprocessing import Pool
---> 10 from rdkit import Chem
     11 from rdkit.Chem.rdMolDescriptors import CalcNumRotatableBonds
     12 from easydock.database import create_db, restore_setup_from_db, init_db, update_db, save_sdf, select_mols_to_dock, \
     13     add_protonation

File [e:\Software\Anaconda3\envs\easydock\lib\site-packages\rdkit\Chem\__init__.py:23](file:///E:/Software/Anaconda3/envs/easydock/lib/site-packages/rdkit/Chem/__init__.py:23)
     21 _HasSubstructMatchStr = rdchem._HasSubstructMatchStr
     22 from rdkit.Chem.rdchem import *
---> 23 from rdkit.Chem.rdmolfiles import *
     24 from rdkit.Chem.rdmolops import *
     25 from rdkit.Chem.rdCIPLabeler import *

ImportError: DLL load failed while importing rdmolfiles: The specified procedure could not be found.
DrrDom commented 9 months ago

Hi, this seems like an issue with RDKit, the code cannot import RDKit modules. How do you run docking? Do you run code within a jupyter notebook? Could you provide the while code you run? We never tested how easydock worked in jupyter. However, the current error is linked to RDKit import.

BuiQuocDung1991 commented 9 months ago

I use anaconda as pakage manager and vscode in order to code with jupyter notebook (not jupyter in anaconda). After installing and activating easydock environment in anaconda prompt, i choose this kernel in vscode. After that, my code snippet is as below:

from easydock.run_dock import docking
from easydock.vina_dock import mol_dock
# from easydock.gnina_dock import mol_dock  # <- enable gnina docking
from rdkit import Chem

smiles = ['CC(=O)O', 'NCC(=O)O', 'NC(C)C(=O)O']
mols = [Chem.MolFromSmiles(smi) for smi in smiles]

# assign names, because this will be an identifier of docking outputs of a molecule 
for mol, smi in zip(mols, smiles):
    mol.SetProp('_Name', smi)

for mol_id, res in docking(mols, dock_func=mol_dock, dock_config='config.yml', ncpu=4):
    print(mol_id, res)

I want to run docking in python directly instead of in autodock.

DrrDom commented 9 months ago

The error is clearly in RDKit import. Try to import RDKit modules alone without any other code, you will get the same error. I believe the issue is in RDKit installation. For example

from rdkit.Chem import *
BuiQuocDung1991 commented 9 months ago

The issue is in RDKit installation. I have no idea what happened with rdkit. The proplem is in from rdkit.Chem.rdmolfiles import * What shoud i do to run easydock in python?

DrrDom commented 9 months ago

As I understood, you want to run easydock in an interactive mode using ipython. In this case I cannot advise something if you have an error with running RDKit. However, you may always use a command line python script. The one which we have in the package or write your own script which will satisfy your particular needs.

BuiQuocDung1991 commented 7 months ago

i think that the problem comes from python version 's compatibility. You can read the same problem here: https://github.com/rdkit/rdkit/discussions/6268

DrrDom commented 7 months ago

So, the solution would be to downgrade python version? On which python version it worked well? I still use 3.9 in all my environments.

BuiQuocDung1991 commented 7 months ago

Maybe, the issue is in the version of python. I have no idea exactly what happened but i guess. when i make new env environment with below codes:

conda create -n env python anaconda -y
conda install -c conda-forge rdkit -y 

The version of python is 3.11 When i run jupiter in VS code, this error appeared: ImportError: DLL load failed when importing Chem Then i attempt to reinstall with below code (of course i removed the previous env environment) conda create -c conda-forge -n env rdkit -y The error disappeared with python 3.10.

DrrDom commented 7 months ago

Thank you for reporting this issue and the solution.