Trying to setup cx_Oracle and ZcxOracleDA on a Plone/Zope Zeo setup using the Unified Installer (Plone 3.3.5), I had the following error when starting a zeo client: “ImportError: libclntsh.so.10.1: cannot open shared object file: No such file or directory”. Here is a solution.

Steps required

  • Oracle installation
  • cx_Oracle installation in the python used by Zope/Plone. Don’t forget to test your connectivity with the Oracle database:
$ cd <zope-install>
$ ./Python-2.4/bin/python
Python 2.4.6 [...]
>>> import cx_Oracle
>>> connection = cx_Oracle.connect('<user-name>/<user-password>@<db-name>')
>>> cursor = connection.cursor()
>>> cursor.execute("select count(*) from mytable").fetchall()
[(200805,)]
  • ZcxOracleDA untarred in the “products” directory

libclntsh.so.10.1: cannot open shared object file ???

$ cd <zope-install>/zeocluster
$ ./bin/client1 fg
2010-12-02 14:55:33 INFO ZServer HTTP server started at Thu Dec  2 14:55:33 2010
        Hostname: 0.0.0.0
        Port: 8080
2010-12-02 14:55:33 INFO Zope Set effective user to "plone"
[...]
  File "build/bdist.linux-x86_64/egg/cx_Oracle.py", line 6, in __bootstrap__
ImportError: libclntsh.so.10.1: cannot open shared object file: \
No such file or directory

The Zope instance is running with the effective user “plone”, who apparently has no right to access Oracle libraries.

The user “plone” needs access to the Oracle libraries

Add a home directory and a shell for “plone”:

$ sudo usermod -s /bin/bash -d /home/plone plone
$ sudo chown plone:plone /home/plone
$ sudo chmod 750 /home/plone

Add the user “plone” to a group that has access to the Oracle librairies, in my case “oinstall”:

$ sudo gpasswd -a plone oinstall

$ORACLE_HOME and $LD_LIBRARY_PATH must be exported from his .bashrc or ~/.bash_profile file:

$ sudo su - plone
(plone)$ cd ~
(plone)$ vim .bashrc
export ORACLE_HOME=/opt/oracle/oracle/product/10.2.0/db_1                               
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
(plone)$ ln -s ~/.bashrc ~/.bash_profile
(plone)$ sqlplus
SQL*Plus: Release 10.2.0.1.0 - Production on Thu Dec 2 15:46:00 2010
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
Enter user-name:

And voila!