Difference between revisions of "Install (source code)"

From Open Babel
Jump to: navigation, search
(Information on libxml2-dev and zlib.h)
(Instructions for non-root install)
Line 1: Line 1:
 
=== Step-by-step Installation Instructions for OpenBabel ===
 
=== Step-by-step Installation Instructions for OpenBabel ===
  
These instructions describe the installation procedure for OpenBabel 2.0.2. For more different releases, the version number will be different and you should take this in account when reading the instructions below. In addition, these instructions assume that you have root access.
+
These instructions describe the installation procedure for OpenBabel 2.0.2. For more different releases, the version number will be different and you should take this in account when reading the instructions below. In addition, these instructions assume that you have root access. If you don't have root access, see [[Install (source code)#Installing locally without root access | Installing locally without root access]].
  
 
(1) [http://sourceforge.net/project/showfiles.php?group_id=40728&package_id=32894&release_id=434410 Download] the latest version (2.0.2, currently)
 
(1) [http://sourceforge.net/project/showfiles.php?group_id=40728&package_id=32894&release_id=434410 Download] the latest version (2.0.2, currently)
Line 76: Line 76:
 
   import _openbabel
 
   import _openbabel
 
ImportError: libopenbabel.so.1: cannot open shared object file: No such file or directory
 
ImportError: libopenbabel.so.1: cannot open shared object file: No such file or directory
 +
</pre>
 +
 +
==== Installing locally without root access ====
 +
 +
If you don't have root access, you can still compile and use Open Babel.
 +
 +
(a) Follow Steps 1 to 3 above
 +
 +
(b) Make a local directory to install everything into. In this example, I will use the folder "tree" in my home directory:
 +
<pre>
 +
mkdir /home/noel/tree
 +
</pre>
 +
 +
(c) Instead of Step 4 above, use the 'prefix' option of configure as follows:
 +
<pre>
 +
./configure --prefix=/home/noel/tree | tee configure.out
 +
make | tee make.out
 +
</pre>
 +
 +
(d) You can now install without root permissions using the following command:
 +
<pre>
 +
make install
 +
</pre>
 +
 +
This installs the babel executable (and related tools) to /home/noel/tree/bin so you need to add this directory to your PATH in your startup scripts (that is, .bashrc, or whatever):
 +
<pre>
 +
export PATH=$PATH:/home/noel/tree/bin
 +
</pre>
 +
 +
(e) To compile the Python extension, follow Step 6 above.
 +
 +
(f) To install the Python extension, instead of Step 7 above, use the 'prefix' option to setup.py:
 +
<pre>
 +
python setup.py install --prefix=/home/noel/tree
 +
</pre>
 +
 +
This installs the Python extension into something like /home/noel/tree/lib/python2.3/site-packages, so you need to add this directory to your PYTHONPATH in your startup scripts (that is, .bashrc, or whatever):
 +
<pre>
 +
export PYTHONPATH=$PYTHONPATH:/home/noel/tree/lib/python2.3/site-packages
 +
</pre>
 +
 +
(g) As described in Step 8 above, you will probably also have to edit the variable LD_LIBRARY_PATH as follows:
 +
<pre>
 +
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/oboyle/tree/lib
 
</pre>
 
</pre>
  

Revision as of 07:09, 10 January 2007

Step-by-step Installation Instructions for OpenBabel

These instructions describe the installation procedure for OpenBabel 2.0.2. For more different releases, the version number will be different and you should take this in account when reading the instructions below. In addition, these instructions assume that you have root access. If you don't have root access, see Installing locally without root access.

(1) Download the latest version (2.0.2, currently)

(2) Open a command window, change directory into 'openbabel', and decompress the downloaded file with following command:

tar zxvf openbabel-2.0.2.tar.gz

This will create a folder called 'openbabel-2.0.2'.

(3) What do you need to compile openbabel?

Requirements:

  • A C++ compiler (like g++)
  • A makefile system (like GNU make)

Optional tools/libraries:

  • Python is required to compile the Python bindings
  • Perl is required to compile the Perl bindings
  • SWIG is required to recreate the Python/Perl bindings (this is only necessary for developers...see below for more info)
  • libxml2 development headers are required to read/write CML files (the libxml2-dev package in Ubuntu)
  • zlib.h is required to support reading gzipped files (the zlib1g-dev package in Ubuntu)

(4) You now need to configure and compile openbabel. To do this, change directory into 'openbabel-2.0.2'. Run the following commands, one after the other

./configure | tee configure.out
make | tee make.out

If there are any errors at this point, send an email to the openbabel-discuss mailing list and attach the files 'configure.out' and 'make.out'.

If you look at the output of 'configure' you can see whether CML and gzip support will be included in openbabel (see Optional Libraries above).

...
checking for libxml - version >= 2.6.5...yes (version 2.6.21)
...
checking for zlib.h... yes

(5) If you have root permissions, you should install openbabel globally. As root, run the following command:

make install

(6) If you want to use OpenBabel from Python, you now need to compile the python extension. This may require an extra Python package depending on your Linux distribution. For example, for Debian you need the 'python-dev' package (installed using 'apt-get'); for SUSE, you need 'python-devel' (installed using YaST).

Change directory to 'openbabel-2.0.2/scripts/python' and run:

python setup.py build

(7) To install the python interface globally, as root type:

python setup.py install

(8) You may need to add the location of libopenbabel.so.1 (on my system, the location is /usr/local/lib) to the environment variable LD_LIBRARY_PATH if you get the following error when you try to import the OpenBabel library at the Python prompt:

$ python
>>> import openbabel 
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.4/site-packages/openbabel.py", line 9, in ?
   import _openbabel
ImportError: libopenbabel.so.1: cannot open shared object file: No such file or directory

Installing locally without root access

If you don't have root access, you can still compile and use Open Babel.

(a) Follow Steps 1 to 3 above

(b) Make a local directory to install everything into. In this example, I will use the folder "tree" in my home directory:

mkdir /home/noel/tree

(c) Instead of Step 4 above, use the 'prefix' option of configure as follows:

./configure --prefix=/home/noel/tree | tee configure.out
make | tee make.out

(d) You can now install without root permissions using the following command:

make install

This installs the babel executable (and related tools) to /home/noel/tree/bin so you need to add this directory to your PATH in your startup scripts (that is, .bashrc, or whatever):

export PATH=$PATH:/home/noel/tree/bin

(e) To compile the Python extension, follow Step 6 above.

(f) To install the Python extension, instead of Step 7 above, use the 'prefix' option to setup.py:

python setup.py install --prefix=/home/noel/tree

This installs the Python extension into something like /home/noel/tree/lib/python2.3/site-packages, so you need to add this directory to your PYTHONPATH in your startup scripts (that is, .bashrc, or whatever):

export PYTHONPATH=$PYTHONPATH:/home/noel/tree/lib/python2.3/site-packages

(g) As described in Step 8 above, you will probably also have to edit the variable LD_LIBRARY_PATH as follows:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/oboyle/tree/lib

Advanced Notes

  • If you need to recompile the SWIG bindings for the openbabel module, make sure you have the latest version of SWIG installed, and at Step (3) above, run configure as follows: ./configure --enable-maintainer-mode