I have installed oracle client and oracle client-dev, and setup ORACLE_HOME environment variable. Yet when I attempt to install tux_oracle (python setup.py build) I get the following: fatal error: oci.h: No such file or directory
3 Answers 3
Well, the answer is to install cx_Oracle not tx_Oracle. The way to do it in Ubuntu is the following:
- You must have the oracle client installed in your PC. If not download from oracle http://www.oracle.com/technetwork/topics/linuxsoft-082809.html.
- Install alien in your PC to be able to convert rpm to deb:
sudo apt-get -i alien
- Convert the rpm to deb:
sudo alien -d oracle-instantclient11.2-sqlplus-11.2.0.2.0.i386.rpm
- Install
sudo dpkg -i oracle-instantclient11.2-basic_11.2.0.2.0-2_i386.deb
- Set ORACLE_HOME environment variable in /etc/profile.d by creating a file oracle.sh which must contain:
export ORACLE_HOME=/usr/lib/oracle/11.2/client source oracle.sh
- Update LD_LIBRARY_PATH:
sudo vi /etc/ld.so.conf.d/oracle.conf which must contain: "$ORACLE_HOME/lib" sudo ldconfig
- Download and install cx_Oracle (depending on the version of oracle and python you are using) from http://cx-oracle.sourceforge.net/ Again convert rpm to deb using alien and install:
sudo alien -d cx_Oracle-5.1-11g-py32-1.i386.rpm sudo dpkg -i cx-oracle_5.1-2_i386.deb
- cx_Oracle gets installed in /usr/lib/python2.7/dist-packages/. You must do: sudo mv site-packages/cx_Oracle* dist-packages/ sudo rmdir site-packages/ sudo ln -s dist-packages site-packages
Now you should have no problem connecting to oracle. From python type:
import cx_Oracle
To connect to the database specify a connection string in tsnames.ora or directly:
connection_string = 'username/password@(DESCRIPTION= (ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521))(CONNECT_DATA= (SID=MY_SID)))'
1 Comment
That header file can be found in the development suite. For some reason, it's not included in the default distribution package. Have a look at
http://my.opera.com/onyxluo/blog/cannot-find-oci-h-in-oracle9-2-client
Here's the page content, for your convenience. I got it from Google cache as the page was down when I got there.
The reason of this problem is because OCI (Oracle Call Interface)package is not installed in Oracle9.2 client. The default path of "oci.h" is $ORACLE_HOME/rdbms/demo. This problem doesn't exist on Oracle Database 9.2.0.1. But for Oracle 9.2.0.1 client, OCI package is not included in client even if you select the full package of client installation.
Solution:
- install Oracle 9.2.0.1 client first.
- In OUI(Oracle Universal Installer), use the same oracle home with Oracle 9.2.0.1 client, and then select Oracle Database install.
- Choose Customized in database installation
- Uncheck Enterprise Manager and Oracle Database and others except OCI and OCCI.
After OCI installed, $ORACLE_HOME/rdbms/demo will contain oci.h and other *.h files.