Skip to content

Instantly share code, notes, and snippets.

@alchem0x2A
Last active December 11, 2019 15:20
Show Gist options
  • Save alchem0x2A/3c33460e7c29d5e5a197d538e2c524ad to your computer and use it in GitHub Desktop.
Save alchem0x2A/3c33460e7c29d5e5a197d538e2c524ad to your computer and use it in GitHub Desktop.
Installing Python binding for openbabel on HPC

Problem

Python binding for openbabel might be not trivial to install on HPC cluster. Simple pip install openbabel are very likely to fail. Sample error messages are like:

Error: SWIG failed. Is Open Babel installed?
    You may need to manually specify the location of Open Babel include and library directories. For example:
      python setup.py build_ext -I/usr/local/include/openbabel-2.0 -L/usr/local/lib
      python setup.py install
    ----------------------------------------

Solution

First, check if swig is installed or loaded in the HPC system. The build process requires it, although the website of openbabel does not specify.

The setup.py of openbabel Python-binding may be a bit messy. As indicated by the error message, the include and library paths needed to be specified. To find the actual version of openbabel that is linked in the HPC, run something like:

env | grep openbabel

where the root path of openbabel installed may be like /cluster/apps /openbabel/.

You can specify these parameters via the global_option, like:

OPENBABEL_DIR=/cluster/apps/openbabel/2.4.1/x86_64 #Change it according to your system
pip install --global-option=build_ext --global-option="-I$OPENBABEL_DIR/include/openbabel-2.0" --global-option="-L$OPENBABEL_DIR/lib" openbabel

Note the suffix openbabel-2.0 must be present. Generally after these steps the Python binding should be installed smoothly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment