Preparing system
It is good to update and upgrade your Ubuntu system first. Log into your Ubuntu system and open the terminal by pressing Ctrl+Alt+T altogether, and type the following commands:
$ sudo apt-get update
$ sudo apt-get upgrade
Downloading Openbabel
Change to the directory where you want to download (here, it is Downloads). Open a terminal and paste the following command to download Openbabel or visit this page to download.
$ cd Downloads/
$ wget https://github.com/openbabel/openbabel/archive/refs/heads/master.zip
Installing required dependencies
Install the following libraries before proceeding.
$ sudo apt-get install cmake gcc g++ make libeigen3-dev libboost-all-dev
Installing Openbabel
Unzip the downloaded file.
$ unzip master.zip
It will create a new directory namely openbabel-master. Move inside this directory and make a new directory namely, build.
$ cd openbabel-master/
$ mkdir build
Move inside the build directory.
$ cd build/
Run the following commands to build Openbabel.
$ cmake ..
$ make
$ sudo make install
$ sudo ldconfig
Installing Python bindings for Openbabel
First, add openbabel to your environment using the following command.
$ export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
Now, install the Python bindings.
$ pip install openbabel
or
$ pip3 install openbabel
Check if Open Babel and the Python bindings are installed correctly:
$ obabel -V
It should display the version.
References
- O’Boyle, N. M., Banck, M., James, C. A., Morley, C., Vandermeersch, T., & Hutchison, G. R. (2011). Open Babel: An open chemical toolbox. Journal of cheminformatics, 3, 1-14.