rdkit / conda-rdkit

Conda build recipe for the rdkit
50 stars 30 forks source link

RuntimeError when using numpy <1.13 #57

Open marta-sd opened 6 years ago

marta-sd commented 6 years ago

Hi,

I have troubles working with the newest version of RDKit together with not-the-newest version of numpy.

It seems like rdkit package requires numpy=1.13, although it is not stated in the dependencies. The simplest example that doesn't work (tested on Ubuntu 16.04):

conda create -c rdkit -n rdkit_test python=3.6 numpy=1.12 rdkit=2017.09.1
source activate rdkit_test

and then in Python I get this error:

>>> import rdkit
>>> from rdkit import Chem
RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa
RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa
RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/martas/miniconda3/envs/rdkit_test/lib/python3.6/site-packages/rdkit/Chem/__init__.py", line 25, in <module>
    from rdkit.Chem.rdmolops import *
SystemError: initialization of rdmolops raised unreported exception

Note that importing rdkit doesn't raise the exception. Also, when I use Python 2.7 I get slightly different error:

>>> from rdkit import Chem
RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa
RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa
RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/martas/miniconda3/envs/rdkit_py27/lib/python2.7/site-packages/rdkit/Chem/__init__.py", line 25, in <module>
    from rdkit.Chem.rdmolops import *
ImportError: numpy.core.multiarray failed to import

When I create the environment with numpy v. 1.13 everything works fine (checked in Py3.6 and Py2.7).

mwojcikowski commented 6 years ago

It might be like glibc compatibility, so that the compiled version is the oldest supported. That way if we compile with numpy 1.13 the requirement is numpy => 1.13.

marta-sd commented 6 years ago

Update: @mwojcikowski compiled rdkit with numpy=1.12, and indeed it works both with 1.12 and 1.13

greglandrum commented 6 years ago

That's strange... the version of the code that I did the conda builds from (the development branch) does actually specify a numpy version: https://github.com/rdkit/conda-rdkit/blob/development/rdkit/meta.yaml maybe I screwed something up when I did the builds.

I guess you're on linux?

marta-sd commented 6 years ago

Yes, I'm using linux.

If I understood correctly, this line: https://github.com/rdkit/conda-rdkit/blob/7e80fec107a1dd887ae24fdcf9878c08f7c80c8f/rdkit/meta.yaml#L25 should be numpy ==1.12. When its >=1.12, conda can use the most recent version (1.13) to build this package and then it doesn't support the older one (1.12).

Note, that this line: https://github.com/rdkit/conda-rdkit/blob/7e80fec107a1dd887ae24fdcf9878c08f7c80c8f/rdkit/meta.yaml#L43 should stay as it is.

greglandrum commented 6 years ago

Got it. Thanks. @rvianello : does this seem right to you too?

rvianello commented 6 years ago

yes, I couldn't test it, but it makes sense to me. I think conda build also supported a specific syntax that was intended to define the runtime requirements based on what was used at build time, but this is also changing a bit in version 3.x, so the proposed constraints should be fine for now.