Compiling Open Babel with Python bindings
This blog will show you how to compile Open Babel from source with Python bindings.
🛠️ How to Compile Open Babel with Python Bindings
Use the commands below to compile Open Babel from source with Python bindings:
git clone git://github.com/openbabel/openbabel.git
cd openbabel
mkdir build
cd build
cmake -DRUN_SWIG=ON -DPYTHON_BINDINGS=ON \
-DCMAKE_INSTALL_PREFIX=/opt/openbabel \
-DENABLE_TESTS=ON ..
make
make test
sudo make install
🧪 Environment Variables
To use your newly compiled Open Babel, export the following environment variables:
export PYTHONPATH=/opt/openbabel/lib/python2.7/site-packages:$PYTHONPATH
export LD_LIBRARY_PATH=/opt/openbabel/lib:$LD_LIBRARY_PATH
export PATH=/opt/openbabel/bin:$PATH
You’re now ready to use Open Babel with Python!