molinfo-vienna / CDPKit

The Chemical Data Processing Toolkit
https://cdpkit.org
GNU Lesser General Public License v2.1
75 stars 10 forks source link

Errors when import CDPL #9

Closed OlgaGKononova closed 1 year ago

OlgaGKononova commented 1 year ago

Hello,

I am trying to run example form README to test installation.

Case 1: CDPKit is installed in conda environment (cloned repo and ran pip install -e .), PYTHONPATH is empty. When trying import CDPL, getting the following error:

>>> from CDPL import Chem
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/vagrant/CDPKit/Libs/Python/CDPL/__init__.py", line 37, in <module>
    from ._cdpl import *
ModuleNotFoundError: No module named 'CDPL._cdpl'

Case 2: I built CDPKit from source code into /progs/cdpk folder, added /progs/cdpk/Include to PYTHONPATH. When trying example, getting the following error:

>>> from CDPL import Chem
>>> from CDPL import Pharm
>>> mol = Chem.parseSMILES('Cc1ccccc1')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'CDPL.Chem' has no attribute 'parseSMILES'

I will appreciate any help with it.

seidelt commented 1 year ago

Hi Olga,

I can see the following potential reasons why it might not be working:

case 1: For editable installs you have to create a virtual python environment and activate it. Did you do that? Have a look here: https://setuptools.pypa.io/en/latest/userguide/development_mode.html

case 2: The PYTHONPATH has to be set to /progs/cdpk/Python not /progs/cdpk/Include (which contains C++ headers only).

Hope my answers will be of help!

OlgaGKononova commented 1 year ago

Hi Thomas,

Case 1: wasn't able to install it with pip install . - failed to build wheels, looking into problem at the moment.

Case 2: the problem is that after installation there is no /progs/cdpk/Python folder. Only Bin, Examples, Include, and Libs are in that folder. Hence, CDPL cannot be found during import. I do install it following the procedure in README with only modification:

 cmake ~/CDPKit/ -DCMAKE_INSTALL_PREFIX=/progs/cdpk/1.0.0/ -DBOOST_ROOT=/progs/boost/1.76.0

The rest is same. cmake == 3.23.1, gcc == 12.1.0

seidelt commented 1 year ago

Ok, now I understand! You also have to install the CDPKit dependencies that are needed for compiling the Python wrapper. Have a closer look at the Installation chapter at cdpkit.org and install the listed dependencies. Alternatively you can also do just a 'pip install cdpkit' which will install the latest stable CDPL Python release from PyPI!

OlgaGKononova commented 1 year ago

oh, okay. Looks like I missed boost-python3-devel installation for installation from source. Also, installing release from PyPl also worked. Thank you.